aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Level.elm
blob: 8b28ad3192c63163405f5ed9b7cc537c7dc604fa (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
module Model.Level
  ( currentLevel
  , progressiveColor
  ) where

import Time exposing (Time)
import Debug

import Model.Color exposing (..)

levelScoreDuration : Int
levelScoreDuration = 20

type alias Level =
  { color : Color
  }

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 }
    }
  , { color = { red = 190, green = 156, blue = 233 }
    }
  , { color = { red = 233, green = 156, blue = 232 }
    }
  , { color = { red = 233, green = 156, blue = 187 }
    }
  , { color = { red = 233, green = 171, blue = 156 }
    }
  , { color = { red = 233, green = 215, blue = 156 }
    }
  , { color = { red = 206, green = 233, blue = 156 }
    }
  , { color = { red = 162, green = 233, blue = 156 }
    }
  , { color = { red = 156, green = 233, blue = 196 }
    }
  , { color = { red = 156, green = 225, blue = 233 }
    }
  ]

lastLevel : Level
lastLevel =
  { color = { red = 156, green = 225, blue = 233 }
  }