diff --git a/right_coin.lua b/right_coin.lua index 26e5372..ec84f9e 100644 --- a/right_coin.lua +++ b/right_coin.lua @@ -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