aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Player.elm
blob: 37a1a7f604bf3e5f40eb4cbffdcdd457091fd990 (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 =
  (levelCurve Level.levelScoreDuration 15 (Level.currentLevelScore score)) + 15

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