displaying text while the program is loading
BlitzPlus Forums/BlitzPlus Beginners Area/displaying text while the program is loading
| ||
I have a game where I am loading a bunch of images and sounds upfront so when the executable is launched it takes a while for the game to start. Is there a way I can display 'Loading' maybe even with a status bar while this is happening? |
| ||
Well there is nothing stopping you to write "Loading" at the screen and flip it before you start loading all your gamedata (images and sound). If you want a statusbar you might need to call a function between every load or maybe set up a function for the loading itself retrieving loading data and in between always update the statusbar. Just remember to flip it :) |
| ||
I hope this helps, this is a complete example of something that might be like what you want ;This method creates a GUI window on the desktop and sets a progress bar on it ;Lets say you have 5 images and 5 sounds to load loadwindow = CreateWindow("",(ClientWidth(Desktop()) / 2) - 225,(ClientHeight(Desktop()) / 2) - 125,450,250,Desktop(),0) label = CreateLabel("Loading...",205,100,70,15,loadwindow) loadbar = CreateProgBar(140,135,180,20,loadwindow) ;Now just update the progbar after each image and sound a = LoadImage("a.bmp") UpdateProgBar(loadbar,.1);Update it based on the amount of images and sounds that have been loaded divided by the total, in this case, 1 / 10 = .1 b = LoadImage("b.bmp") UpdateProgBar(loadbar,.2) c = LoadImage("c.bmp") UpdateProgBar(loadbar,.3) d = LoadImage("d.bmp") UpdateProgBar(loadbar,.4) e = LoadImage("e.bmp") UpdateProgBar(loadbar,.5);Halfway done now, time for the sounds f = LoadSound("f.wav") UpdateProgBar(loadbar,.6) g = LoadSound("g.wav") UpdateProgBar(loadbar,.7) h = LoadSound("h.wav") UpdateProgBar(loadbar,.8) i = LoadSound("i.wav") UpdateProgBar(loadbar,.9) j = LoadSound("j.wav") UpdateProgBar(loadbar,1) Delay 2000;Wait 2 seconds just so people can get a good look at the progress bar FreeGadget loadwindow;Get rid of loadwindow and all its child gadget, now you can start the main program code ;At least on my computer it just loaded them all so fast that the progress bar looked like it started at the top, but if you deal with larger images/sounds, the load times will be longer ;If you want to see the progress bar go up slowly, you could put a delay statement after each UpdateProgBar ;Also, you can add a canvas and decorate up the load screen a bit |
| ||
it would be easier with select:loading% = True, index% = 1, totalindex% = 5 Repeat UpdateLoadingBar(Float index% / totalindex%) index% = index% + 1 Select index% Case 1 LoadImage() Case 2 LoadSound() Case 3 LoadSomeMore() Case 4 LoadEvenMore() Case 5 loading% = False End Select Until Not loading% |
| ||
thanks |