Keeping track of game state (menu, game over, splash screen, etc) can be tricky. This video give you an easy way of doing this using variables for _update and _draw that are called for each state.
I use a table to store the variables but, for the token-conscious amongst you, you could just use variables.
See my blog for a more detailed description: gamedev.docrobs...
The basic code is below:
game={}
function _update()
game.upd()
end
function _draw()
game.drw()
end
function show_state()
game.upd = state_update
game.drw = state_screen_draw
end
or for the token watchers out there:
function _update()
game_upd()
end
function _draw()
game_drw()
end
function show_state()
game_upd = state_update
game_drw = state_screen_draw
end
19 сен 2024