set initial game state
This commit is contained in:
parent
94d8135a92
commit
d068315fff
|
@ -166,6 +166,13 @@ do -- Player
|
||||||
local accel=0.3
|
local accel=0.3
|
||||||
local decel=0.5
|
local decel=0.5
|
||||||
|
|
||||||
|
function Player:new(o)
|
||||||
|
o = o or {}
|
||||||
|
self.__index = self
|
||||||
|
setmetatable(o, self)
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
||||||
function Player:direct()
|
function Player:direct()
|
||||||
if btn(2) then
|
if btn(2) then
|
||||||
self:goLeft()
|
self:goLeft()
|
||||||
|
@ -494,14 +501,24 @@ function draw(state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function update(state)
|
function setInitialGameState()
|
||||||
if currentState == GameState.start then
|
p=Player:new()
|
||||||
if btnp(4) then -- A (Z key)
|
|
||||||
currentState = GameState.game
|
|
||||||
t=0
|
t=0
|
||||||
secondsAlive=0
|
secondsAlive=0
|
||||||
life=100
|
life=100
|
||||||
dropInitialCoins()
|
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
|
end
|
||||||
elseif currentState == GameState.game then
|
elseif currentState == GameState.game then
|
||||||
updateGame()
|
updateGame()
|
||||||
|
|
Loading…
Reference in a new issue