Game Level/Stage Breakup

Blitz3D Forums/Blitz3D Programming/Game Level/Stage Breakup

Craig H. Nisbet(Posted 2003) [#1]
I'm wondering if anyone has any strategies on how to program the progression from stage to stage im a game. By stage I mean for example; Title screen to level 1 to GamePlay to EndLevel, and so forth. The reason I ask is because I always end writing code that has a main game loop, then try to incorporate changing levels and title screens. I always have a problem at this point. My guess for a better solution would be to brake each state into it's own loop so that I can jump between those stages with out having to throw all kinds of conditional code into one main game loop. I hope this makes sense. Any ideas on this?


Ross C(Posted 2003) [#2]
well when i write code my main game loop usually looks like this

while not keyhit(1)

  ...stuff for player control, keyhit(200) then blah

  update_player()
  update_enemys()
  update_physics()
  update_camera()

wend


so everything has its own function. sory to stray from the point. i'd put in a status variable called status (orginal).
so it would be

While Not Keyhit(1)
  
  
  
  If status=0 Then
              update_title_screen
  ElseIf status=1 Then
              update gameplay
  ElseIf status=2 Then
              update_ending
  End If

  UpdateWorld
  RenderWorld
  Flip
Wend

Function update_title_screen()
   if keyhit(200) then
                 move_menu_down()
   elseif keyhit.....blah
                 blah
   blah-blah
End Function

etc
etc
etc


so that if the character dies then you simply set the variable status to 0 and up pops the main menu. hope some of this helps.


Mustang(Posted 2003) [#3]
Yup, and before:

while not keyhit(1)

  ...stuff for player control, keyhit(200) then blah

  update_player()
  update_enemys()
  update_physics()
  update_camera()

wend


 InitializeScreen(AndOtherUserSettings)
 LoadLevel(EitherStartOrSavedGame)


...So you load either the first level if user chose "New Game" or you load previously saved game if the user wanted that. All your levels should use same kind of gameplay techniques (triggers, collisions, AI etc) so that it does NOT matter what level you load; every level works basically the same way.

Of course you should include additional info to your level loading function, like positions of the enemies (start and/or saved game positions).

My FPS-game will have some sort of (even short) movie (real-time, using the game engine and 3rd person instead of 1st) between every level that carries the story forward and to the next level (literally!), so that's one way to do that.