From e49e42ad3410d5654cdee5c81a1d0957736941b8 Mon Sep 17 00:00:00 2001 From: Pascal Batty Date: Sun, 28 Apr 2019 15:41:04 +0200 Subject: [PATCH] Coins now respawn --- right_coin.lua | 5 +++++ 1 file changed, 5 insertions(+) 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