-
Notifications
You must be signed in to change notification settings - Fork 0
/
Collision.elm
27 lines (20 loc) · 1.15 KB
/
Collision.elm
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
module Collision exposing (..)
import MapSetting exposing (..)
rightImpact speed time posList playerPos =
(posList|> List.filter (projectionOverlap .y1 .y2 playerPos)
|> List.filter (\pos -> (playerPos.x2 - speed.x * time < pos.x1) && (playerPos.x2 > pos.x1))
|> List.isEmpty) == False
leftImpact speed time posList playerPos =
(posList|> List.filter (projectionOverlap .y1 .y2 playerPos)
|> List.filter (\pos -> (playerPos.x1 - speed.x * time > pos.x2) && (playerPos.x1 < pos.x2))
|> List.isEmpty) == False
downImpact speed time posList playerPos =
(posList|> List.filter (projectionOverlap .x1 .x2 playerPos)
|> List.filter (\pos -> (playerPos.y2 - speed.y * time <= pos.y1) && (playerPos.y2 >= pos.y1))
|> List.isEmpty) == False
upImpact speed time posList playerPos =
(posList|> List.filter (projectionOverlap .x1 .x2 playerPos)
|> List.filter (\pos -> (playerPos.y1 - speed.y * time >= pos.y2) && (playerPos.y1 <=pos.y2))
|> List.isEmpty) == False
projectionOverlap min max pos1 pos2=
(pos1 |> min) < (pos2 |> max) && (pos1 |> max) > (pos2 |> min)