Skip to content

Instantly share code, notes, and snippets.

@Achie72
Created November 5, 2023 10:52
Show Gist options
  • Save Achie72/5619e7e99b4d9799dc3eeed8f612fa91 to your computer and use it in GitHub Desktop.
Save Achie72/5619e7e99b4d9799dc3eeed8f612fa91 to your computer and use it in GitHub Desktop.
Lina: Suika Hunt - Scene System
-- we start with the scene variable in init
scene = "menu"
-- then in update
function _update()
-- increase the tick
t+=1
if t > 29 then
t = 0
seconds += 1
end
-- switch to different custom update functions
-- based on which scenes we are in
if scene == "menu" then
update_menu()
elseif scene == "game" then
update_game()
end
end
-- now for ex. in for the menu
function update_menu()
-- in the menu as of now we only need to press
-- x to start the game
if btnp(5) then
-- switch to game scene
scene = "game"
-- reset variables to a new game state
seconds = 0
fruitCollection = {}
score = 0
playerComboString = ""
end
end
-- and we do this for draw calls as well
function _draw()
if scene == "menu" then
draw_menu()
elseif scene == "game" then
draw_game()
end
print(scene, 0, 8, 8)
end
-- draw menu we just simply print a highscore
function draw_menu()
cls()
print("HighScore: "..savedHighScore)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment