aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Level.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/Level.elm')
-rw-r--r--src/Model/Level.elm67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Model/Level.elm b/src/Model/Level.elm
new file mode 100644
index 0000000..8b28ad3
--- /dev/null
+++ b/src/Model/Level.elm
@@ -0,0 +1,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 }
+ }