-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|713|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Forklift_Fred
Created : 28 January 2008
 
Language : Blitz

Simple Progress Bar

Simple but with potential for more complexity

A basic entry level addition to fill the time while you wait.

I felt the need for one while my Halloween Maze game loaded the graphics and sounds but it could also be used for a time bar or health meter.

For a "Loading data" progress bar it needs to be called after each file, but how else would it update?

I've included 4 display options for the counter and left it at that. (If you don't specify one then it will just draw the bar)



Obviously you can fiddle with the function to change the positioning of the counter and change the colours to suit or make the border into a solid fill... I thought about building these in as parameters but didn't want to bloat the function unnecessarily... Keep it simple and let everyone else adapt it for their needs.

The demo program included does some random counting and simulates unequal file sizes by using a random delay between updates. The important parameters when calling the function are:

current# - the current step through the progression (which file you are up to)
total# - how many steps there are (how many files to load)

The only one that should change between calls therefore is current#

Watch this space for an Advanced Progress Bar complete with all the bloated options!

 

Comments


Tuesday, 29 January 2008, 09:49
JL235
The problem with GUIs made in this style is that you are redrawing the entire GUI on everyframe. In a real GUI you will only redraw what has been updated.

But still, very nice.
Tuesday, 29 January 2008, 12:17
Forklift_Fred
Like I said, it's entry level. It's just 2 rectangles and that's what is being updated anyway.

I felt inspired by someone else's snippet and for some reason remembered this and thought "That was an obvious snippet that was missing when I wanted it, I'll post what I made"

Little things lead to bigger ideas, or cover laziness when you have other things to focus on