set initial game state
This commit is contained in:
parent
94d8135a92
commit
d068315fff
|
@ -166,6 +166,13 @@ do -- Player
|
|||
local accel=0.3
|
||||
local decel=0.5
|
||||
|
||||
function Player:new(o)
|
||||
o = o or {}
|
||||
self.__index = self
|
||||
setmetatable(o, self)
|
||||
return o
|
||||
end
|
||||
|
||||
function Player:direct()
|
||||
if btn(2) then
|
||||
self:goLeft()
|
||||
|
@ -494,14 +501,24 @@ function draw(state)
|
|||
end
|
||||
end
|
||||
|
||||
function update(state)
|
||||
if currentState == GameState.start then
|
||||
if btnp(4) then -- A (Z key)
|
||||
currentState = GameState.game
|
||||
function setInitialGameState()
|
||||
p=Player:new()
|
||||
t=0
|
||||
secondsAlive=0
|
||||
life=100
|
||||
dropInitialCoins()
|
||||
sickCounter=20 -- how many seconds before the sickness get stronger?
|
||||
sickLapse=20 -- how many ticks before the life decreases?
|
||||
coinBlue=0
|
||||
coinRed=0
|
||||
coinYellow=0
|
||||
end
|
||||
|
||||
function update(state)
|
||||
if currentState == GameState.start then
|
||||
if btnp(4) then -- A (Z key)
|
||||
currentState = GameState.game
|
||||
setInitialGameState()
|
||||
end
|
||||
elseif currentState == GameState.game then
|
||||
updateGame()
|
||||
|
|
Loading…
Reference in a new issue