aboutsummaryrefslogtreecommitdiff
path: root/src/CloudStep.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2014-10-08 22:13:41 +0200
committerJoris Guyonvarch2014-10-08 22:27:11 +0200
commitd37a301ed39bac823e0f2223b8d229b417e128c7 (patch)
treee7e1155e8678bfb32908452993234078527d6664 /src/CloudStep.elm
parent4521cdf1bb5725c9d497e5fb0c03943ad03a052f (diff)
Adding a power to change the player color that reverse points to catch and points to avoid
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
}