aboutsummaryrefslogtreecommitdiff
path: root/src/Update
diff options
context:
space:
mode:
Diffstat (limited to 'src/Update')
-rw-r--r--src/Update/CloudUpdate.elm30
-rw-r--r--src/Update/Update.elm16
2 files changed, 23 insertions, 23 deletions
diff --git a/src/Update/CloudUpdate.elm b/src/Update/CloudUpdate.elm
index 1fbb9d3..359f02c 100644
--- a/src/Update/CloudUpdate.elm
+++ b/src/Update/CloudUpdate.elm
@@ -15,16 +15,16 @@ import Model.Level exposing (..)
import Utils.Geometry exposing (..)
-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
+cloudUpdate : Float -> Vec2 -> Seed -> Player -> Float -> Cloud -> Int -> (Cloud, Int, Seed)
+cloudUpdate elapsedTime boardSize seed player playerSize {points, spawn, lastSpawn} currentScore =
+ let pointsToCatch = presentPoints elapsedTime boardSize (points player.config)
+ presentAndNotCaughtPoints = List.filter (not << (playerPointCollision elapsedTime player playerSize)) pointsToCatch
addScore = (List.length pointsToCatch) - (List.length presentAndNotCaughtPoints)
- presentOtherPoints = presentPoints time boardSize (points (otherConfig player.config))
+ presentOtherPoints = presentPoints elapsedTime boardSize (points (otherConfig player.config))
(newCloud, seed') =
- if time > lastSpawn + spawn then
- let (newPoint1, seed') = getNewPoint time boardSize seed currentScore
- (newPoint2, seed'') = getNewPoint time boardSize seed' currentScore
+ if elapsedTime > lastSpawn + spawn then
+ let (newPoint1, seed') = getNewPoint elapsedTime boardSize seed currentScore
+ (newPoint2, seed'') = getNewPoint elapsedTime boardSize seed' currentScore
in ( { points = \config ->
if(config == player.config)
then
@@ -32,7 +32,7 @@ cloudUpdate time boardSize seed player {points, spawn, lastSpawn} currentScore =
else
newPoint2 :: presentOtherPoints
, spawn = spawn - sqrt(spawn) / 50
- , lastSpawn = time
+ , lastSpawn = elapsedTime
}
, seed''
)
@@ -50,19 +50,19 @@ cloudUpdate time boardSize seed player {points, spawn, lastSpawn} currentScore =
in (newCloud, addScore, seed')
presentPoints : Float -> Vec2 -> List Point -> List Point
-presentPoints time boardSize points =
- let isPresent point = (distance (pointMove point time) originVec) < (pointAwayDist boardSize)
+presentPoints elapsedTime boardSize points =
+ let isPresent point = (distance (pointMove point elapsedTime) originVec) < (pointAwayDist boardSize)
in List.filter isPresent points
getNewPoint : Float -> Vec2 -> Seed -> Int -> (Point, Seed)
-getNewPoint time boardSize seed currentScore =
+getNewPoint elapsedTime boardSize seed currentScore =
let (initPos, seed') = pointInitPos boardSize seed
(initDest, seed'') = pointDestination boardSize seed'
- in ( { initTime = time
+ in ( { initTime = elapsedTime
, initPos = initPos
, initDest = initDest
- , move = \initTime initPos initDest time ->
- let delta = time - initTime
+ , move = \initTime initPos initDest elapsedTime ->
+ let delta = elapsedTime - initTime
move = (currentLevel currentScore).move initPos initDest delta
in initPos `add` move
}
diff --git a/src/Update/Update.elm b/src/Update/Update.elm
index 9dc737f..2514aac 100644
--- a/src/Update/Update.elm
+++ b/src/Update/Update.elm
@@ -25,20 +25,20 @@ import Input exposing (Input)
update : Input -> Game -> Game
update input game =
let hostilePoints = game.cloud.points (otherConfig game.player.config)
- in if(playerPointsCollision game.time game.player hostilePoints)
+ in if(playerPointsCollision game.elapsedTime game.player (getPlayerSize game.currentScore) hostilePoints)
then
{ game
- | time = 0
+ | elapsedTime = 0
, currentScore = 0
, cloud = initCloud
- , rounds = (Round game.time game.currentScore) :: game.rounds
+ , rounds = (Round game.elapsedTime game.currentScore) :: game.rounds
}
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 game.currentScore
+ let newPlayer = playerStep input.delta game.boardSize input.dir (newKeyCode game.keysDown input.inputKeysDown) game.player (getPlayerSize game.currentScore)
+ (newCloud, addScore, newSeed) = cloudUpdate game.elapsedTime game.boardSize game.seed newPlayer (getPlayerSize game.currentScore) game.cloud game.currentScore
in
{ game
- | time = game.time + input.delta
+ | elapsedTime = game.elapsedTime + input.delta
, keysDown = input.inputKeysDown
, currentScore = game.currentScore + addScore
, player = newPlayer
@@ -46,8 +46,8 @@ update input game =
, seed = newSeed
}
-playerStep : Float -> Vec2 -> Vec2 -> (KeyCode -> Bool) -> Player -> Player
-playerStep dt boardSize dir newKey player =
+playerStep : Float -> Vec2 -> Vec2 -> (KeyCode -> Bool) -> Player -> Float -> Player
+playerStep dt boardSize dir newKey player playerSize =
let (pos, speed) = getNewPosAndSpeed dt dir playerSpeed (player.pos, player.speed)
newConfig = if (newKey 69) then otherConfig player.config else player.config
in { pos = inBoard boardSize playerSize pos