From 361dcb7d0f0a99e1f586efeff3918d4f0b300560 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 29 Apr 2019 13:16:21 +0200 Subject: [PATCH] make life deadlier --- right_coin.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/right_coin.lua b/right_coin.lua index 8cb718e..f79020a 100644 --- a/right_coin.lua +++ b/right_coin.lua @@ -22,6 +22,8 @@ valueYellow=0.8 MarketOptions = { blue=0, red=1, yellow=2, all=3, done=4 } marketSelection = MarketOptions.blue secondsAlive=0 +sickCounter=20 -- how many seconds before the sickness get stronger? +sickLapse=20 -- how many ticks before the life decreases? solids={} do @@ -519,12 +521,18 @@ function updateGame() currentState = GameState.gameover return end - if t%20 == 0 then + if t%sickLapse == 0 then life=life-1 end if t%60 == 0 then + sickCounter = sickCounter - 1 secondsAlive = secondsAlive + 1 end + if sickCounter==0 and sickLapse>3 then + sickLapse=sickLapse-2 + sickCounter=20 + end + p:direct() p:update() @@ -534,9 +542,6 @@ function updateGame() currentState = GameState.market end end - -- if btnp(5) then -- B (X key) - -- currentState = GameState.gameover - -- end if coinTimer>0 then coinTimer=coinTimer-1 end if coinTimer == 0 then for i=1, coinSpawnCount do @@ -544,12 +549,12 @@ function updateGame() end end - -- Coin market + -- Coin market, capped to 9.9 valueBlue=math.floor((math.sin(t/200)+1)*50)/10 if t%60 == 0 then valueRed=math.random(0,99)/10 end - valueYellow=0.1*coinYellow*coinYellow + valueYellow=math.min(.1*coinYellow*coinYellow, 9.9) end function updateMarket()