Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Loading Bar?

Author
Message
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 3rd Nov 2011 03:54
Sorry for doing another topic so soon. But I'm just wondering how to do a loading bar type thing. I can do this (Though still probably not the best way.)



But how do I actually have it load and check the bytes loaded?
I'm clueless.

Until someone actually answers, I'm going hunting through file commands.

fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 3rd Nov 2011 06:20
just use that method but put it between your loading code kinda like this:



i know its not real code but just use the idea.
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 3rd Nov 2011 06:36
But wouldnt that load it multiple times? And it doesnt track the actual amount of data loaded, it just has a set time. It will probably work, but it's not a bug I'm dealing with. Just wanted to see if there are any commands to detect that.

fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 3rd Nov 2011 06:50 Edited at: 3rd Nov 2011 06:51
sorry i misread your post a little bit.

as far as commands to figure out how much is loaded from a specific file i cant help you there. but if you just wanted to figure out how much is loaded from the overall amount of files i think you could do this:

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 3rd Nov 2011 07:26
Again, still not very helpful, I was just hoping for a little tutorial on how to determen (Sorry for spelling) how much data a file has and how much has been read and loaded in from that file, then make the loading bar stretch to one side and get bigger.

Still waiting for some help to come along.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Nov 2011 07:59 Edited at: 3rd Nov 2011 08:01
Personally, I will only use a loading bar when it take several seconds or longer for the game to load. For a game with 1500 lines and 12 pieces of media, I won't waste the time.

Anyway, to answer your question, it depends more upon the time it takes to load your media, not just the number of bytes. This will depend upon the type of media. You could calculate this by reading the timer() before and after the load and calculating the elapsed time. You then could change the loading bar sprite % based upon the elapsed times of the different files.

There are other ways to do it, but this worked okay for me.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2011 09:21 Edited at: 3rd Nov 2011 09:24
Quote: "Again, still not very helpful, I was just hoping for a little tutorial on how to determen (Sorry for spelling) how much data a file has and how much has been read and loaded in from that file, then make the loading bar stretch to one side and get bigger.

Still waiting for some help to come along."


It depends on what your loading.

If your loading media it should be fast enough to not bother as LBFN suggested but if it's thousands of files do fllwthewolves method.

If your loading a text file with 1000 lines then you know when the 1000th line is loaded it's loaded 100% (LastLineLoaded*100)/MaxLines.

If your loading a database with different data types then you calculate the size of the file in bytes vs how many bytes one individual record takes. Like if you had a file size of 5000 and an individual record takes up 100 bytes then you know that the file has 50 records because (FileSize/RecordSize) = MaxRecords and to find out how much has been loaded you do (LastLoadedRecord*100)/MaxRecords.

I just posted the opposite of this (a health bar that starts full and decreases)... this one starts at zero and increases:


LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Nov 2011 15:20
Looks nice, Grog. Granted, I haven't had much coffee yet this morning, but it seems to me that you would need to know the total load time for all files. Then you could divide that by the number of files in order to determine at what point you increase the loading bar. You are using tim + 100 as a trigger, but it would need to be determined. Also, it seems this would need to be written as a subroutine / function and not as a DO - LOOP.

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 3rd Nov 2011 17:33 Edited at: 3rd Nov 2011 17:46
So you find out the file sizes and calculate how long it will take to load by means of percentage? Also this is just a matter of learning, I don't care if I ever even have to make one, just that I know how for if it ever comes up.

EDIT: I made a health bar (For practice, plus my game needed one )
but it doesnt work, its probably something to do with "Stretch sprite" but idk. Here's the code (Look in "TrackHealth" function)



LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Nov 2011 17:44
Yes, that is how I would do it. See how long all of your media takes to load in total so that you know how long to wait before you update the %. Let's say, for example, it takes 4500 ms in total to load, you would know that every 45 ms, you would increase the % by 1. Grog's DO - LOOP would work fine as a subroutine. You would replace the 'tim+100' with 'tim + 45' at that point and simply call the subroutine after each media item is loaded.

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Nov 2011 17:47 Edited at: 3rd Nov 2011 17:48
Also, no body says you must use a loading bar; lots of games just use a splash screen, text screen, hourglass cursor or a looped sequence just to keep the user informed that the program is busy.

However; as was stated, to create a loading bar, you simple draw it to the length (or set a sprite to the frame) representing what stage you are in based on file sizes; number of polygons loaded etc, within the given process eg:

Progress = 0 : size sprite LoadingBar, Progress, 20 : Sync (Or leave Sync out if necessary)
Progress = 50 : size sprite LoadingBar, Progress, 20 : Sync
load image B
Progress = 100: size sprite LoadingBar, Progress, 20 : Sync

Ofcourse this is a basic example, and may not be the best in your scenario; probably you'd create a function that will set the progress and adjust the sprite size automatically. And you do not have to use a sprite, nor do you have to deal with lengths and your progress indicator does not have to be a bar.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2011 18:24 Edited at: 3rd Nov 2011 18:29
Quote: "Looks nice, Grog."


Thanks

Quote: "Granted, I haven't had much coffee yet this morning, but it seems to me that you would need to know the total load time for all files. Then you could divide that by the number of files in order to determine at what point you increase the loading bar."


The time it takes shouldn't be used since different files (like 3D objects) may take longer to load and since everybody's computer is different (HD speed, processor, memory speed) we'd have to load all media twice to determine how long it takes on the users computer. Even using a base line load time on his computer will be off if it's loaded on another persons computer. Going by just the total number of files vs the last loaded file is accurate enough. Also since we can't do two things at once it's much easier to do Fllwthewolves method by loading a file, calculate percentage done, load another file, calculate percentage done, and so on. (LastLoadedFile*100)/MaxFiles

Quote: "You are using tim + 100 as a trigger, but it would need to be determined. Also, it seems this would need to be written as a subroutine / function and not as a DO - LOOP.
"


Yeah, this is just an example. The TIMER() is just so anybody running it could see what it's doing easier (instead of filling the bar instantly). I leave it to him (or anybody using that code) to put it into a function and remove the TIMER() so it works as it should without delay. If I made all my examples modular people would just cut and paste and be less likely to learn something.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Nov 2011 19:05 Edited at: 11th Nov 2011 18:18
Grog, your method is good and is a reasonable solution.
I can't say that I have actually measured the difference of media loading on different computers to see if it is that significant. Perhaps the next time I need to make a loading bar, I will take the time to see.


Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Nov 2011 21:31
I recommend the combo of a splash screen and a loading bar. It is nice while being informative. Loading bars aren't for enjoyment, rather to show the player that they aren't waiting for nothing, that the program didn't hang up or get stuck forever at one point. It may even provide troubleshooting help if you display what it is loading at the moment.

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 4th Nov 2011 02:09
How can I do smooth collision? This is alot smoother than before, but still kind of buggy.


Also I asked a question that never got answered about 5-6 posts up. It was a question about my malfunctioning health bar

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 4th Nov 2011 14:10
Quote: " Also I asked a question that never got answered about 5-6 posts up. It was a question about my malfunctioning health bar "


Here is a basic code with some concepts (not just for health bars but for borders etc too it implemented correctly). You should be able to incorporate it into your code without too much fuss.



Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 4th Nov 2011 17:41
BAM! And I got lives in there too!



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Nov 2011 07:12
Quote: " how much data a file has and how much has been read and loaded in from that file, then make the loading bar stretch to one side and get bigger."




Your signature has been erased by a mod please reduce it to no larger than 600 x 120.

Login to post a reply

Server time is: 2024-11-22 11:54:25
Your offset time is: 2024-11-22 11:54:25