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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
module Model.Level exposing
( levelScoreDuration
, currentLevel
, currentLevelScore
, currentLevelNumber
, progressiveColor
)
import Time exposing (Time)
import Color as Color exposing (Color)
import List.Nonempty as NE exposing (Nonempty(..), (:::))
import Model.Vec2 as Vec2 exposing (Vec2)
import Utils.Physics as Physics
import Utils.Color as Color
levelScoreDuration : Int
levelScoreDuration = 20
type alias Move = Vec2 -> Vec2 -> Time -> Vec2
type alias Level =
{ moves : Nonempty Move
}
currentLevelScore : Int -> Int
currentLevelScore currentScore =
currentScore - (currentLevelNumber currentScore - 1) * levelScoreDuration
currentLevelNumber : Int -> Int
currentLevelNumber currentScore = currentScore // levelScoreDuration + 1
currentLevel : Int -> Level
currentLevel currentScore = NE.get (currentScore // levelScoreDuration) levels
nextLevel : Int -> Level
nextLevel currentScore = currentLevel (currentScore + levelScoreDuration)
progressiveColor : Int -> Color
progressiveColor currentScore =
let reminder = currentScore `rem` levelScoreDuration
ratio = progressiveRatio reminder levelScoreDuration
currentColor = color currentScore
nextColor = color (currentScore + levelScoreDuration)
in Color.merge ratio nextColor currentColor
progressiveRatio : Int -> Int -> Float
progressiveRatio a b = (toFloat a ^ 7) / (toFloat b ^ 7)
initialColor : Color
initialColor = Color.rgb 156 168 233
color : Int -> Color
color score = Color.spin (toFloat <| 20 * (score // levelScoreDuration)) initialColor
levels : Nonempty Level
levels =
let ma1 = \initPos initDest delta -> Physics.getMove (delta / 20) (initDest `Vec2.sub` initPos)
ma2 = \initPos initDest delta -> Physics.getWaveMove (delta / 20) (initDest `Vec2.sub` initPos) 10 10
ma3 = \initPos initDest delta -> Physics.getSawToothMove (delta / 25) (initDest `Vec2.sub` initPos) 30 10
mb1 = \initPos initDest delta -> Physics.getMove (delta / 18) (initDest `Vec2.sub` initPos)
mb2 = \initPos initDest delta -> Physics.getWaveMove (delta / 18) (initDest `Vec2.sub` initPos) 20 20
mb3 = \initPos initDest delta -> Physics.getSawToothMove (delta / 20) (initDest `Vec2.sub` initPos) 30 15
mc1 = \initPos initDest delta -> Physics.getMove (delta / 13) (initDest `Vec2.sub` initPos)
mc2 = \initPos initDest delta -> Physics.getWaveMove (delta / 16) (initDest `Vec2.sub` initPos) 10 50
mc3 = \initPos initDest delta -> Physics.getSawToothMove (delta / 25) (initDest `Vec2.sub` initPos) 100 15
in Nonempty
{ moves = NE.fromElement ma1 }
[ { moves = NE.fromElement ma2 }
, { moves = NE.fromElement ma3 }
, { moves = Nonempty ma1 [ ma2, ma3 ] }
, { moves = NE.fromElement mb1 }
, { moves = NE.fromElement mb2 }
, { moves = NE.fromElement mb3 }
, { moves = Nonempty mb1 [ mb2, mb3 ] }
, { moves = NE.fromElement mc1 }
, { moves = NE.fromElement mc2 }
, { moves = NE.fromElement mc3 }
, { moves = Nonempty mc1 [ mc2, mc3 ] }
]
|