aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Cloud.elm
blob: e397d16322f2f23d974983f76baf13d27018a365 (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
32
33
34
35
36
37
38
39
40
41
module Model.Cloud exposing
  ( Cloud
  , initCloud
  , playerPointsCollision
  , playerPointCollision
  )

import List

import Model.Point exposing (..)
import Model.Player exposing (..)
import Model.Config exposing (..)

import Utils.Geometry exposing (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 -> Float -> List Point -> Bool
playerPointsCollision elapsedTime player playerSize points =
  let collision = playerPointCollision elapsedTime player playerSize
  in  List.length (List.filter collision points) > 0

playerPointCollision : Float -> Player -> Float -> Point -> Bool
playerPointCollision elapsedTime player playerSize point =
  let pointPos = pointMove point elapsedTime
  in  (distance pointPos player.pos) < pointSize + playerSize