Commit 79a9db1c authored by Joris's avatar Joris

Change points move type and speed at each level

parent 4710e5ac
module Model.Level
( currentLevel
, currentLevelNumber
, progressiveColor
) where
......@@ -7,14 +8,25 @@ import Time exposing (Time)
import Debug
import Model.Color exposing (..)
import Model.Vec2 exposing (..)
import Model.Point exposing (pointSpeed)
import Utils.Physics exposing (getMove, getWaveMove)
levelScoreDuration : Int
levelScoreDuration = 20
levelScoreDuration = 15
type alias Level =
{ color : Color
, move : Vec2 -> Vec2 -> Time -> Vec2
}
currentLevelNumber : Int -> Int
currentLevelNumber currentScore =
min
(List.length levels + 1)
(currentScore // levelScoreDuration + 1)
currentLevel : Int -> Level
currentLevel currentScore =
levels
......@@ -40,28 +52,39 @@ progressiveRatio a b = (toFloat a ^ 7) / (toFloat b ^ 7)
levels : List Level
levels =
[ { color = { red = 156, green = 168, blue = 233 }
, move initPos initDest delta = getMove (delta / 20) (initDest `sub` initPos)
}
, { color = { red = 190, green = 156, blue = 233 }
, move initPos initDest delta = getWaveMove (delta / 20) (initDest `sub` initPos) 10 10
}
, { color = { red = 233, green = 156, blue = 232 }
, move initPos initDest delta = getMove (delta / 18) (initDest `sub` initPos)
}
, { color = { red = 233, green = 156, blue = 187 }
, move initPos initDest delta = getWaveMove (delta / 18) (initDest `sub` initPos) 20 20
}
, { color = { red = 233, green = 171, blue = 156 }
, move initPos initDest delta = getMove (delta / 13) (initDest `sub` initPos)
}
, { color = { red = 233, green = 215, blue = 156 }
, move initPos initDest delta = getWaveMove (delta / 16) (initDest `sub` initPos) 10 50
}
, { color = { red = 206, green = 233, blue = 156 }
, move initPos initDest delta = getMove (delta / 11) (initDest `sub` initPos)
}
, { color = { red = 162, green = 233, blue = 156 }
, move initPos initDest delta = getWaveMove (delta / 14) (initDest `sub` initPos) 30 15
}
, { color = { red = 156, green = 233, blue = 196 }
, move initPos initDest delta = getMove (delta / 8) (initDest `sub` initPos)
}
, { color = { red = 156, green = 225, blue = 233 }
, move initPos initDest delta = getWaveMove (delta / 12) (initDest `sub` initPos) 30 30
}
]
lastLevel : Level
lastLevel =
{ color = { red = 156, green = 225, blue = 233 }
, move initPos initDest delta = getWaveMove (delta / 5) (initDest `sub` initPos) 30 30
}
......@@ -11,20 +11,20 @@ import Model.Board exposing (boardDiagonal)
import Model.Point exposing (..)
import Model.Cloud exposing (..)
import Model.Config exposing (..)
import Model.Level exposing (..)
import Utils.Geometry exposing (..)
import Utils.Physics exposing (getMove, getWaveMove)
cloudUpdate : Float -> Vec2 -> Seed -> Player -> Cloud -> (Cloud, Int, Seed)
cloudUpdate time boardSize seed player {points, spawn, lastSpawn} =
cloudUpdate : Float -> Vec2 -> Seed -> Player -> Cloud -> Int -> (Cloud, Int, Seed)
cloudUpdate time boardSize seed player {points, spawn, lastSpawn} currentScore =
let pointsToCatch = presentPoints time boardSize (points player.config)
presentAndNotCaughtPoints = List.filter (not << (playerPointCollision time player)) pointsToCatch
addScore = (List.length pointsToCatch) - (List.length presentAndNotCaughtPoints)
presentOtherPoints = presentPoints time boardSize (points (otherConfig player.config))
(newCloud, seed') =
if time > lastSpawn + spawn then
let (newPoint1, seed') = getNewPoint time boardSize seed
(newPoint2, seed'') = getNewPoint time boardSize seed'
let (newPoint1, seed') = getNewPoint time boardSize seed currentScore
(newPoint2, seed'') = getNewPoint time boardSize seed' currentScore
in ( { points config =
if(config == player.config)
then
......@@ -54,8 +54,8 @@ presentPoints time boardSize points =
let isPresent point = (distance (pointMove point time) originVec) < (pointAwayDist boardSize)
in List.filter isPresent points
getNewPoint : Float -> Vec2 -> Seed -> (Point, Seed)
getNewPoint time boardSize seed =
getNewPoint : Float -> Vec2 -> Seed -> Int -> (Point, Seed)
getNewPoint time boardSize seed currentScore =
let (initPos, seed') = pointInitPos boardSize seed
(initDest, seed'') = pointDestination boardSize seed'
in ( { initTime = time
......@@ -63,7 +63,7 @@ getNewPoint time boardSize seed =
, initDest = initDest
, move initTime initPos initDest time =
let delta = time - initTime
move = getWaveMove (pointSpeed delta) (initDest `sub` initPos) 50 50
move = (currentLevel currentScore).move initPos initDest delta
in initPos `add` move
}
, seed''
......
......@@ -36,7 +36,7 @@ update input game =
}
else
let newPlayer = playerStep input.delta game.boardSize input.dir (newKeyCode game.keysDown input.inputKeysDown) game.player
(newCloud, addScore, newSeed) = cloudUpdate game.time game.boardSize game.seed newPlayer game.cloud
(newCloud, addScore, newSeed) = cloudUpdate game.time game.boardSize game.seed newPlayer game.cloud game.currentScore
in
{ game
| time <- game.time + input.delta
......
......@@ -144,15 +144,16 @@ renderScore boardSize currentRoundTime rounds score =
{ x = 0.0
, y = boardSize.y / 2 - 35
}
scoreText = "L" ++ (toString << currentLevelNumber <| score) ++ " - " ++ (toString score)
in if currentRoundTime < 5000
then
case List.head rounds of
Just round ->
renderText boardSize scorePos (roundView round)
Nothing ->
renderText boardSize scorePos (toString score)
renderText boardSize scorePos scoreText
else
renderText boardSize scorePos (toString score)
renderText boardSize scorePos scoreText
renderText : Vec2 -> Vec2 -> String -> Svg
renderText boardSize pos content =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment