aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Level.elm
blob: 9a60b9abd90cfbe8cce6301b96ab1b9618efedb7 (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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
module Model.Level exposing
  ( currentLevel
  , currentLevelScore
  , currentLevelNumber
  , progressiveColor
  , levelScoreDuration
  )

import Time exposing (Time)
import Debug

import Model.Color exposing (..)
import Model.Vec2 exposing (..)
import Model.Point exposing (pointSpeed)

import Utils.Physics exposing (getMove, getWaveMove)

levelScoreDuration : Int
levelScoreDuration = 20

type alias Level =
  { color : Color
  , move : Vec2 -> Vec2 -> Time -> Vec2
  }

currentLevelScore : Int -> Int
currentLevelScore currentScore =
  currentScore - (currentLevelNumber currentScore - 1) * levelScoreDuration

currentLevelNumber : Int -> Int
currentLevelNumber currentScore =
  min
    (List.length levels + 1)
    (currentScore // levelScoreDuration + 1)

currentLevel : Int -> Level
currentLevel currentScore =
  levels
    |> List.drop (currentScore // levelScoreDuration)
    |> List.head
    |> Maybe.withDefault lastLevel

nextLevel : Int -> Level
nextLevel currentScore = currentLevel (currentScore + levelScoreDuration)

progressiveColor : Int -> Color
progressiveColor currentScore =
  let reminder = currentScore `rem` levelScoreDuration
      ratio = progressiveRatio reminder levelScoreDuration
      currentColor = (currentLevel currentScore).color
      nextColor = (nextLevel currentScore).color
  in  mergeColors ratio nextColor currentColor

progressiveRatio : Int -> Int -> Float
progressiveRatio a b = (toFloat a ^ 7) / (toFloat b ^ 7)

-- Hue + 35 with gimp each time from the first color
levels : List Level
levels =
  [ { color = { red = 156, green = 168, blue = 233 }
    , move = \initPos initDest delta -> getMove (delta / 20) (initDest `sub` initPos)
    }
  , { color = { red = 190, green = 156, blue = 233 }
    , move = \initPos initDest delta -> getWaveMove (delta / 20) (initDest `sub` initPos) 10 10
    }
  , { color = { red = 233, green = 156, blue = 232 }
    , move = \initPos initDest delta -> getMove (delta / 18) (initDest `sub` initPos)
    }
  , { color = { red = 233, green = 156, blue = 187 }
    , move = \initPos initDest delta -> getWaveMove (delta / 18) (initDest `sub` initPos) 20 20
    }
  , { color = { red = 233, green = 171, blue = 156 }
    , move = \initPos initDest delta -> getMove (delta / 13) (initDest `sub` initPos)
    }
  , { color = { red = 233, green = 215, blue = 156 }
    , move = \initPos initDest delta -> getWaveMove (delta / 16) (initDest `sub` initPos) 10 50
    }
  , { color = { red = 206, green = 233, blue = 156 }
    , move = \initPos initDest delta -> getMove (delta / 11) (initDest `sub` initPos)
    }
  , { color = { red = 162, green = 233, blue = 156 }
    , move = \initPos initDest delta -> getWaveMove (delta / 14) (initDest `sub` initPos) 30 15
    }
  , { color = { red = 156, green = 233, blue = 196 }
    , move = \initPos initDest delta -> getMove (delta / 8) (initDest `sub` initPos)
    }
  , { color = { red = 156, green = 225, blue = 233 }
    , move = \initPos initDest delta -> getWaveMove (delta / 12) (initDest `sub` initPos) 30 30
    }
  ]

lastLevel : Level
lastLevel =
  { color = { red = 156, green = 225, blue = 233 }
  , move = \initPos initDest delta -> getWaveMove (delta / 5) (initDest `sub` initPos) 30 30
  }