Coins now respawn

master
Pascal Batty 2019-04-28 15:41:04 +02:00
parent 26c70dd8b7
commit e49e42ad34
1 changed files with 5 additions and 0 deletions

View File

@ -60,6 +60,8 @@ function hitTest(rect1, rect2)
and rect1.y + rect1.h > rect2.y
end
coinCooldown=120
coinTimer=coinCooldown
colors={"blue","red","yellow"}
spawnLocs={
{x=28*8,y=5*8},
@ -127,6 +129,7 @@ function addRandomCoin()
newCoin.x=loc.x
newCoin.y=loc.y
coins[#coins + 1]=newCoin
coinTimer=coinCooldown
end
-- MOCK
@ -431,6 +434,8 @@ function updateGame()
if btnp(5) then -- B (X key)
currentState = GameState.gameover
end
if coinTimer>0 then coinTimer=coinTimer-1 end
if coinTimer == 0 then addRandomCoin() end
p:direct()
p:update()
end