From d37a301ed39bac823e0f2223b8d229b417e128c7 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 8 Oct 2014 22:13:41 +0200 Subject: Adding a power to change the player color that reverse points to catch and points to avoid --- src/CloudStep.elm | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/CloudStep.elm') diff --git a/src/CloudStep.elm b/src/CloudStep.elm index e33d573..65609cb 100644 --- a/src/CloudStep.elm +++ b/src/CloudStep.elm @@ -8,26 +8,33 @@ import Point (..) import RandomValues (..) import Physics (getMove) import Cloud (..) +import Config (..) cloudStep : Float -> RandomValues -> Player -> Cloud -> (Cloud, Int) -cloudStep time {greenPoint, redPoint} player {greenPoints, redPoints, spawn, lastSpawn} = - let insideGreenPoints = presentPoints time greenPoints - insideNotCaughtGreenPoints = filter (not . (playerPointCollision time player)) insideGreenPoints - addScore = (length insideGreenPoints) - (length insideNotCaughtGreenPoints) - presentRedPoints = presentPoints time redPoints +cloudStep time randomValues player {points, spawn, lastSpawn} = + let pointsToCatch = presentPoints time (points player.config) + presentAndNotCaughtPoints = filter (not . (playerPointCollision time player)) pointsToCatch + addScore = (length pointsToCatch) - (length presentAndNotCaughtPoints) + presentOtherPoints = presentPoints time (points (otherConfig player.config)) newCloud = if time > lastSpawn + spawn then - let newGreenPoint = newPoint time greenPoint - newRedPoint = newPoint time redPoint + let newPoint1 = newPoint time randomValues.point1 + newPoint2 = newPoint time randomValues.point2 in - { greenPoints = newGreenPoint :: insideNotCaughtGreenPoints - , redPoints = newRedPoint :: presentRedPoints + { points config = + if(config == player.config) then + newPoint1 :: presentAndNotCaughtPoints + else + newPoint2 :: presentOtherPoints , spawn = spawn - sqrt(spawn) / 50 , lastSpawn = time } else - { greenPoints = insideNotCaughtGreenPoints - , redPoints = presentRedPoints + { points config = + if(config == player.config) then + presentAndNotCaughtPoints + else + presentOtherPoints , spawn = spawn , lastSpawn = lastSpawn } -- cgit v1.2.3