"Loading" Screens

Blitz3D Forums/Blitz3D Programming/"Loading" Screens

anomaly(Posted 2004) [#1]
how do you make the program stop, while you wait for loading things like models and levels and such? like show a backdrop that says Loading, while everything loads up, then continuing...


Hujiklo(Posted 2004) [#2]
Use a timer and a global variable?

if loading =1
spamscreen=spamscreen+1
if spamscreen = 200
loading=0
endif
endif
if loading=0
***show your picture***
else
***start your game***
endif


just a quick thought that's all.


Ross C(Posted 2004) [#3]
If you wanting a loading screen in your game whilst things load, you'd be best to think out a structure for your game. Perhaps having a mode variable. Then the main loop could be like so:

While Not KeyHit(1)

    If mode = 0 then
        loading_screen()
    ElseIf mode = 1 then
        level1()
    ElseIf mode = 2 then
        level2()
    ElseIf mode = 3 then
        game_over_screen()
    ElseIf mode = 4 then
        high_score_screen()
    End If

Wend
End


That way, whenever you want something to happen, just set the mode variable to say 0 for the loading screen to appear, or if you finish level 1, set mode to 2. A bit simplified, but it's always good to plan it out a little. Makes it alot easier to keep track of and debug.


sswift(Posted 2004) [#4]
Anomaly:
The simplest way to make a loading screen is to just hide or free everything you have loaded for the previous level, and then display a quad over the screen with your loading texture, renderworld and flip, and then load your stuff. If you want to have your loading screen have a progress bar, then just change the size of your progress bar after each thing is loaded, and render and flip again.

If you don't want to bother hiding stuff, then just use entityorder to put a black quad over the whole screen temporarily, or move the camera somewhere far away in the world.

In a language like C, one might be able to make a very accurate progress bar which is updated in the background as the files are actually loaded, progressing as the file is actually loaded, but that's overkill anyway.


gburgess(Posted 2004) [#5]
Rather than use a quad, what about loadbuffer()? Just slap a picture up on the screen?


John Pickford(Posted 2004) [#6]
Ross, are you aware of select,case?


 select GAME_STATE

    case GS_TITLE

      ;title page code here

    case GS_LOADSTUFF

      ;loading screen code

    case GS_GAMEPLAY

      ;gameplay code

  end select



A bit more elegant than all those if's acting on ths same variable.


John Pickford(Posted 2004) [#7]
sswift,

I keep ALL entities hidden by default, usually parented to various pivots.

 
    showentity game_switch
    renderworld()
    hideentity game_switch

    showentity scanner_switch  ;overlaid scanner
    renderworld()
    hideentity scanner_switch


game_switch is a pivot and is also the parent of everything in the game window - including the camera.

Likewise scanner_switch controls various elements used for an overlaid scanner which has it's own camera (with smaller viewport). The scanner renders neatly on top of the main screen with no chance of z-buffer interference or any other problems. The scanner camera is set to clear zbuffer but not colour buffer.

I actually have 5 or 6 renderworlds going on by default. Nice and neat with no speed issues. Much better IMO than putting the camera in some odd place where it can't see anything.


_PJ_(Posted 2004) [#8]
I have a splash screen that is drawn to the backbuffer as normal, FLIPped once to display it, then where everything loads in (plus a Delay 1000 to ensure an absolute minimum display of one second) without another flip so the screen doesn't get affected.


joerae(Posted 2004) [#9]
Another quick addition which I discovered yesterday is great for pause screens (and some loading screens).

If you want the 3D level to appear static in the background as the 2D loading screen covers part of it, then use 'grabimage' to take a screenshot of it. Then draw the freshly grabbed image in the background before you draw the loading screen (or menu screen) on top of it.

If you're inbetween levels, you can then kill all of the 3D entities, and update the world while the user still sees a picture of the previous level in the background, if that floats your boat.