aboutsummaryrefslogtreecommitdiff
path: root/src/Cloud.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2014-10-05 23:10:18 +0200
committerJoris Guyonvarch2014-10-05 23:10:32 +0200
commit4521cdf1bb5725c9d497e5fb0c03943ad03a052f (patch)
tree8b7247e9b1b2c950c7bec39548bfe860965c5126 /src/Cloud.elm
parentc2583cf7ff8684d1194c61ab132e23d7ccebcd51 (diff)
downloadcatchvoid-4521cdf1bb5725c9d497e5fb0c03943ad03a052f.tar.gz
catchvoid-4521cdf1bb5725c9d497e5fb0c03943ad03a052f.tar.bz2
catchvoid-4521cdf1bb5725c9d497e5fb0c03943ad03a052f.zip
Adding multiple moving points to catch
Diffstat (limited to 'src/Cloud.elm')
-rw-r--r--src/Cloud.elm31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Cloud.elm b/src/Cloud.elm
new file mode 100644
index 0000000..081862c
--- /dev/null
+++ b/src/Cloud.elm
@@ -0,0 +1,31 @@
+module Cloud where
+
+import Point (..)
+import Player (..)
+import Geometry (distance)
+
+type Cloud =
+ { greenPoints : [Point]
+ , redPoints : [Point]
+ , spawn : Float
+ , lastSpawn : Float
+ }
+
+initCloud : Cloud
+initCloud =
+ let spawn = 200
+ in { greenPoints = []
+ , redPoints = []
+ , spawn = spawn
+ , lastSpawn = -spawn
+ }
+
+playerPointsCollision : Float -> Player -> [Point] -> Bool
+playerPointsCollision time player points =
+ let collision = playerPointCollision time player
+ in length (filter collision points) > 0
+
+playerPointCollision : Float -> Player -> Point -> Bool
+playerPointCollision time player point =
+ let pointPos = pointMove point time
+ in (distance pointPos player.pos) < pointSize + playerSize