aboutsummaryrefslogtreecommitdiff
path: root/src/CloudStep.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/CloudStep.elm')
-rw-r--r--src/CloudStep.elm29
1 files changed, 18 insertions, 11 deletions
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
}