Coins now respawn
This commit is contained in:
parent
26c70dd8b7
commit
e49e42ad34
|
@ -60,6 +60,8 @@ function hitTest(rect1, rect2)
|
||||||
and rect1.y + rect1.h > rect2.y
|
and rect1.y + rect1.h > rect2.y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
coinCooldown=120
|
||||||
|
coinTimer=coinCooldown
|
||||||
colors={"blue","red","yellow"}
|
colors={"blue","red","yellow"}
|
||||||
spawnLocs={
|
spawnLocs={
|
||||||
{x=28*8,y=5*8},
|
{x=28*8,y=5*8},
|
||||||
|
@ -127,6 +129,7 @@ function addRandomCoin()
|
||||||
newCoin.x=loc.x
|
newCoin.x=loc.x
|
||||||
newCoin.y=loc.y
|
newCoin.y=loc.y
|
||||||
coins[#coins + 1]=newCoin
|
coins[#coins + 1]=newCoin
|
||||||
|
coinTimer=coinCooldown
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MOCK
|
-- MOCK
|
||||||
|
@ -431,6 +434,8 @@ function updateGame()
|
||||||
if btnp(5) then -- B (X key)
|
if btnp(5) then -- B (X key)
|
||||||
currentState = GameState.gameover
|
currentState = GameState.gameover
|
||||||
end
|
end
|
||||||
|
if coinTimer>0 then coinTimer=coinTimer-1 end
|
||||||
|
if coinTimer == 0 then addRandomCoin() end
|
||||||
p:direct()
|
p:direct()
|
||||||
p:update()
|
p:update()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue