Block of code, Process BAr while being processed

Blitz3D Forums/Blitz3D Beginners Area/Block of code, Process BAr while being processed

Apollonius(Posted 2004) [#1]
I want to make a Process Bar, like while the game is executing a piece of code theres a process bar going from 0% to 100%, how would you go about doing that?


Rob Farley(Posted 2004) [#2]
http://www.blitzbasic.com/codearcs/codearcs.php?code=286


jhocking(Posted 2004) [#3]
Um, that example is pretty non-instructive. It doesn't help you at all figuring out how much progress has been made, it simply draws a rectangle.

The typical approach to doing a progress bar is to increment the percentage complete between steps in your code. For example, while loading a level you would start percentage complete at 0, then increase to 20 after loading the mesh, then 40 after loading sounds, 60 after setting up the characters, etc. Then, as in the linked code, draw the bar every frame based on the percentage complete.

There may be a way to determine progress more accurately and/or continuously, tracking the movement of data into memory, but I don't know how.


_PJ_(Posted 2004) [#4]
I would work out the ratio's of code that you are loading:

i.e.:

Meshes: 4 MB
Sounds: 8MB
Images: 5MB
Fonts and other crap: 1MB

(or more specifically, per file etc.) then you can assign the percentage to each part. AFAIK, the loading rate is pretty similar regardless of data type (although the onboard sound on my Laptop usually takes a little bit longer)


soja(Posted 2004) [#5]
As it happens, Kaisuo is probably still working in BlitzPlus (right, Kaisuo?), and there is a built-in progress bar gadget. Just look up CreateProgrBar and UpdateProgBar in the docs for a good example.

The only question then would be when to call UpdateProgBar, and with what size delta. That would depend on your code and what you're doing.


eBusiness(Posted 2004) [#6]
Incooperate as many fixpoints in the loading proces as you can, then make your program write a log file with delta time for every fix point (preferably at the user side). In this way you should even be able to show a very correct remaining time.


Apollonius(Posted 2004) [#7]
Im using BlitzPlus but I'm not making a Program, its an ingame loading proccess that I want to do