how can i improve this game structure?

Blitz3D Forums/Blitz3D Beginners Area/how can i improve this game structure?

Santiworld(Posted 2009) [#1]
hi... i need an advice for the new game structure..

game style : Race car game


the program structure is like this..


.menu
  clearworld()
  while 
    if race_start then gosub race
    menu loop
  wend

end 

.race

  clearworld()
  load ode world and ode things
    while (race)
    race loop
    wend

  destroy ode things

gosub menu



this is a good structure for the game?


big10p(Posted 2009) [#2]
Using GoSub in a 'good structure' is an oxymoron. ;)


Santiworld(Posted 2009) [#3]
:) how can i aboid to use gosubs?


big10p(Posted 2009) [#4]
Use functions instead.


Gabriel(Posted 2009) [#5]
A game state system would be better IMO.

Something like

Select GameState
   Case GAMESTATE_MENU
      clearworld()
      while 
         if race_start then State=GAMESTATE_RACE
         menu loop
      wend

   Case GAMESTATE_RACE
      clearworld()
      load ode world and ode things
      while (race)
         race loop
      wend

      destroy ode things
      GameState=GAMESTATE_RACE

End Select



Santiworld(Posted 2009) [#6]
Thanks Gabriel! :)


Ross C(Posted 2009) [#7]
Yeah, break it down further in each function, so it's simplier to keep track of your game.