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