aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Player.elm
blob: 50efb4bfee82e50d97df91b1dc9da60a435656d0 (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
module Model.Player exposing
  ( Player
  , initPlayer
  , getPlayerSize
  , playerSpeed
  )

import Model.Vec2 exposing (..)
import Model.Config exposing (..)
import Model.Level as Level

type alias Player =
  { pos : Vec2
  , speed : Vec2
  , config : Config
  }

initPlayer : Player
initPlayer =
  { pos = originVec
  , speed = originVec
  , config = White
  }

getPlayerSize : Int -> Float
getPlayerSize score =
  15 + (levelCurve Level.levelScoreDuration 15 (Level.currentLevelScore score))

levelCurve : Int -> Int -> Int -> Float
levelCurve maxAbs maxOrd x =
  let linear = toFloat x * toFloat maxOrd / toFloat maxAbs
      n = 4
      exp = toFloat x^n * toFloat maxOrd / toFloat maxAbs^n
  in  linear - exp

playerSpeed : Float -> Float
playerSpeed dt = dt / 200