Skip to content

Instantly share code, notes, and snippets.

@omgmog

omgmog/simple-states.p8

Last active Mar 1, 2019
Embed
What would you like to do?
function _init()
_upd=upd_title
_drw=drw_title
end
function _update()
_upd()
end
function _draw()
_drw()
end
-- title screen state update/draw functions
function upd_title()
-- change to game state when btn 4 is pressed
if btnp(4) then
_upd=upd_game
_drw=drw_game
end
end
function drw_title()
cls(1)
print("title")
end
-- game state update/draw functions
function upd_game()
-- some condition to determine the end of the game
if score < 1 then
_upd=upd_gameover
_drw=drw_gameover
end
end
function drw_game()
cls(2)
print("game")
end
-- gameover state update/draw functions
function upd_gameover()
end
function drw_gameover()
cls(3)
print("game over")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.