blob: fed2981ae074215cb6489ec546799adc71710bc4 (
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
|
module EnemyState where
import Enemy (..)
import Player (..)
import Geometry (distance)
type EnemyState =
{ enemies : [Enemy]
, spawn : Float
, lastSpawn : Float
}
initEnemyState : EnemyState
initEnemyState =
let spawn = 200
in { enemies = []
, spawn = spawn
, lastSpawn = -spawn
}
playerEnemiesCollision : Float -> Player -> [Enemy] -> Bool
playerEnemiesCollision time player enemies =
let collision = playerEnemyCollision time player
in length (filter collision enemies) > 0
playerEnemyCollision : Float -> Player -> Enemy -> Bool
playerEnemyCollision time player enemy =
let enemyPos = enemyMove enemy time
in (distance enemyPos player.pos) < enemySize + playerSize
|