From 17a58e0c4c67f27d87635bf1b2ca50fb11795ad3 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sat, 7 Mar 2015 15:12:02 +0100 Subject: Organizing source code with subdirectories --- src/Model/Cloud.elm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Model/Cloud.elm (limited to 'src/Model/Cloud.elm') diff --git a/src/Model/Cloud.elm b/src/Model/Cloud.elm new file mode 100644 index 0000000..11f6311 --- /dev/null +++ b/src/Model/Cloud.elm @@ -0,0 +1,41 @@ +module Model.Cloud + ( Cloud + , initCloud + , playerPointsCollision + , playerPointCollision + ) where + +import List + +import Model.Point (..) +import Model.Player (..) +import Model.Config (..) + +import Utils.Geometry (distance) + +type alias Cloud = + { points : Config -> List Point + , spawn : Float + , lastSpawn : Float + } + +initCloud : Cloud +initCloud = + let spawn = 600 + in { points config = + case config of + White -> [] + Black -> [] + , spawn = spawn + , lastSpawn = -spawn + } + +playerPointsCollision : Float -> Player -> List Point -> Bool +playerPointsCollision time player points = + let collision = playerPointCollision time player + in List.length (List.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 -- cgit v1.2.3