aboutsummaryrefslogtreecommitdiff
path: root/src/Cloud.elm
blob: 081862c7c27e2cc88f735481dc8d31ca504a28ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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