set initial game state

master
Pascal Batty 2019-04-29 13:35:04 +02:00
parent 94d8135a92
commit d068315fff
1 changed files with 21 additions and 4 deletions

View File

@ -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 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
t=0
secondsAlive=0
life=100
dropInitialCoins()
setInitialGameState()
end
elseif currentState == GameState.game then
updateGame()