Game Development Community

Loading bar... how to do it?

by Typiolin · in Torque Game Builder · 06/15/2006 (5:51 am) · 10 replies

I like the torque Game Engine, but it loads slowly... it's not a problem on itself, but I would like to see something on screen at start and between levels during loadings.

I would like to know how to make a loading bar : can someone point me to the right ressource?

I haven't been able to find it on forums, despite a heavy use of the "search" feature.

#2
06/16/2006 (8:41 pm)
While the resource William linked to is very interesting, I'd also like to know how to load up a graphic as soon as possible after the engine has been initialized.

I tried to insert scripts into common/gamescripts/common.cs initializeCommon() function, after initializeCanvas("TGB"); but before all the rest of the common script files were execed. In theory, there would be enough of an engine to load an image; but nothing I tried worked.

If anybody has any hints on how to best approach this subject; I'd be thrilled to hear their thoughts.
#3
06/18/2006 (11:32 am)
To Don Schaper: you have exactly the same problem as me.

Does someone have any hint ?
#4
06/18/2006 (3:34 pm)
Just use your main.cs file in your TGB.exe root directory to load a gui that displays a picture. Exec the gui file that has the control with the picture, and set the content of your canvas to be that gui. As soon as you can get a handle on your canvas, you can do this. Use the 'setContent' method of the canvas.
#5
06/18/2006 (9:33 pm)
Thank you, Ben. I did as you suggested; execing a simple script to call a GuiFadeinBitmapCtrl gui; right after onStart(), and it worked like a charm. I call loadStartupProject() from that script; after the gui is done. It doesn't, of course, change the time it takes for initializeProject() in projectManagement.cs to load up; but the sense of something happening right away changes the whole startup experience.

The script is ultra-simple:

function pleaseWaitSplash() {
Canvas.hideCursor();
canvas.setContent( pleaseWaitGui );
schedule( 100, 0, checkPleaseWaitSplash );
}

function checkPleaseWaitSplash() {
if ( pleaseWaitGui.done ) {
Canvas.showCursor();
loadStartupProject();
}
else schedule( 100, 0, checkPleaseWaitSplash );
}
#6
06/19/2006 (8:48 am)
Nice!

Though rather than polling, I bet you could set up an "onLevelLoaded" callback system so the splash screen could go away the moment the level is loaded. ;)
#7
06/19/2006 (12:28 pm)
While my script 101 solution is fine for tricking the user into thinking that something is happening, it doesn't actually do anything about covering up the long wait for everything to load. Inserting a callback is the obvious solution. I've already tried it with levelManagement.cs & projectManagement.cs; but there is no appreciable difference. My next attempt is to try the approach on projectResources.cs.

It's entirely possible that there is no script solution. initializeProject() in projectManagement.cs may be the cause of the long wait time. If so, we'd have to shift to the source code for a solution. If it comes to that, I'd probably settle for tricking the user!
#8
06/19/2006 (1:56 pm)
Don, what do you mean by "everything to load"? If your just talking about image datablocks to load, my method will allow you to control what gets loaded and when. You'll also know the progress, and from that can know when its done. My script solution could also be expanded to include audio block as well. Apart from those two data blocks, nothing else really has the startup processing load that would freeze your game.
#9
06/19/2006 (2:54 pm)
I spent a few hours worrying about this issue once, then after some testing in torquescript I realized that all my scripts and resources were loaded even BEFORE my video card had started rendering splash screen! Which is really fast. Unlike TGE and TSE, TGB loads pretty fast if the scripts are already compiled to .dso's because it does not have to light the scene and does not have a lot of the client-server overhead.
#10
06/19/2006 (11:01 pm)
Alex, for the most part you are right. Every game has its own problems. For games with a large image library set load times can get pretty bad. Every image has to be read from disk, decoded, and sent to the video card. Also, not all images can fit on the card once you get over the 32/64MB uncompressed graphic limit (unless your min requirements are a 128MB video card). If you have that many compiled scripts that you're getting load issues, you can delay scripts from loading until after your able to get a splash screen/progress bar on the screen.