Created
May 4, 2013 06:40
-
-
Save dermotbalson/5516500 to your computer and use it in GitHub Desktop.
template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--# 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