Skip to content

Instantly share code, notes, and snippets.

@dermotbalson
Created May 4, 2013 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dermotbalson/5516500 to your computer and use it in GitHub Desktop.
Save dermotbalson/5516500 to your computer and use it in GitHub Desktop.
template
--# Main -- code by Zoyt
function setup()
parameter.integer("Current scene",1,3,1,function(s)
if s == 1 then
changeScene("start")
elseif s == 2 then
changeScene("game")
elseif s == 3 then
changeScene("gameover")
end
end)
end
function draw()
background(40, 40, 50)
scene:draw()
end
function changeScene(s)
if scene ~= nil then
scene:exit()
end
if s == "start" then
scene = Start()
sID = s
elseif s == "game" then
scene = Game()
sID = s
elseif s == "gameover" then
scene = GameOver()
sID = s
else
print("Invalid scene name")
end
end
--# Start
Start = class()
function Start:init()
print("start")
end
function Start:draw()
text("Start screen",WIDTH/2,HEIGHT/2)
end
function Start:exit()
print("exit")
end
--# Game
Game = class()
function Game:init()
print("start")
end
function Game:draw()
text("Game screen",WIDTH/2,HEIGHT/2)
end
function Game:exit()
print("exit")
end
--# GameOver
GameOver = class()
function GameOver:init()
print("start")
end
function GameOver:draw()
text("Game over screen",WIDTH/2,HEIGHT/2)
end
function GameOver:exit()
print("exit")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment