From 2258ef984fefde41711d4c883baf582b7e581155 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 30 Dec 2015 13:35:01 +0100 Subject: Make the player bigger with each point --- src/Model/Cloud.elm | 12 ++++++------ src/Model/Game.elm | 4 ++-- src/Model/Level.elm | 8 +++++++- src/Model/Player.elm | 15 ++++++++++++--- 4 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/Model') diff --git a/src/Model/Cloud.elm b/src/Model/Cloud.elm index 603477b..26b4104 100644 --- a/src/Model/Cloud.elm +++ b/src/Model/Cloud.elm @@ -30,12 +30,12 @@ initCloud = , lastSpawn = -spawn } -playerPointsCollision : Float -> Player -> List Point -> Bool -playerPointsCollision time player points = - let collision = playerPointCollision time player +playerPointsCollision : Float -> Player -> Float -> List Point -> Bool +playerPointsCollision elapsedTime player playerSize points = + let collision = playerPointCollision elapsedTime player playerSize in List.length (List.filter collision points) > 0 -playerPointCollision : Float -> Player -> Point -> Bool -playerPointCollision time player point = - let pointPos = pointMove point time +playerPointCollision : Float -> Player -> Float -> Point -> Bool +playerPointCollision elapsedTime player playerSize point = + let pointPos = pointMove point elapsedTime in (distance pointPos player.pos) < pointSize + playerSize diff --git a/src/Model/Game.elm b/src/Model/Game.elm index 24fd400..97fbc4c 100644 --- a/src/Model/Game.elm +++ b/src/Model/Game.elm @@ -17,7 +17,7 @@ import Model.Round exposing (Round) import Model.Board exposing (initBoardSize) type alias Game = - { time : Float + { elapsedTime : Float , boardSize : Vec2 , keysDown : Set KeyCode , currentScore : Int @@ -29,7 +29,7 @@ type alias Game = initialGame : Seed -> Game initialGame seed = - { time = 0 + { elapsedTime = 0 , boardSize = initBoardSize , keysDown = Set.empty , currentScore = 0 diff --git a/src/Model/Level.elm b/src/Model/Level.elm index 3fc4258..d058d53 100644 --- a/src/Model/Level.elm +++ b/src/Model/Level.elm @@ -1,7 +1,9 @@ module Model.Level ( currentLevel + , currentLevelScore , currentLevelNumber , progressiveColor + , levelScoreDuration ) where import Time exposing (Time) @@ -14,13 +16,17 @@ import Model.Point exposing (pointSpeed) import Utils.Physics exposing (getMove, getWaveMove) levelScoreDuration : Int -levelScoreDuration = 15 +levelScoreDuration = 20 type alias Level = { color : Color , move : Vec2 -> Vec2 -> Time -> Vec2 } +currentLevelScore : Int -> Int +currentLevelScore currentScore = + currentScore - (currentLevelNumber currentScore - 1) * levelScoreDuration + currentLevelNumber : Int -> Int currentLevelNumber currentScore = min diff --git a/src/Model/Player.elm b/src/Model/Player.elm index 2085aac..6858893 100644 --- a/src/Model/Player.elm +++ b/src/Model/Player.elm @@ -1,12 +1,13 @@ module Model.Player ( Player , initPlayer - , playerSize + , getPlayerSize , playerSpeed ) where import Model.Vec2 exposing (..) import Model.Config exposing (..) +import Model.Level as Level type alias Player = { pos : Vec2 @@ -21,8 +22,16 @@ initPlayer = , config = White } -playerSize : Float -playerSize = 15 +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 -- cgit v1.2.3