diff options
author | Joris | 2015-12-30 01:03:47 +0100 |
---|---|---|
committer | Joris | 2015-12-30 01:03:47 +0100 |
commit | 1cf6bc1ad9209e4f3f2fcbc129f2577e74e94c99 (patch) | |
tree | 169e799b2d901a5f89829db8a82c79133e169474 /src/Update | |
parent | 79a9db1c532995c7c760bfb518b43d92dd703280 (diff) |
Upgrade to elm 0.16.0
Diffstat (limited to 'src/Update')
-rw-r--r-- | src/Update/CloudUpdate.elm | 15 | ||||
-rw-r--r-- | src/Update/Update.elm | 23 |
2 files changed, 21 insertions, 17 deletions
diff --git a/src/Update/CloudUpdate.elm b/src/Update/CloudUpdate.elm index e209ced..1fbb9d3 100644 --- a/src/Update/CloudUpdate.elm +++ b/src/Update/CloudUpdate.elm @@ -25,7 +25,7 @@ cloudUpdate time boardSize seed player {points, spawn, lastSpawn} currentScore = if time > lastSpawn + spawn then let (newPoint1, seed') = getNewPoint time boardSize seed currentScore (newPoint2, seed'') = getNewPoint time boardSize seed' currentScore - in ( { points config = + in ( { points = \config -> if(config == player.config) then newPoint1 :: presentAndNotCaughtPoints @@ -37,7 +37,7 @@ cloudUpdate time boardSize seed player {points, spawn, lastSpawn} currentScore = , seed'' ) else - ( { points config = + ( { points = \config -> if(config == player.config) then presentAndNotCaughtPoints else @@ -61,7 +61,7 @@ getNewPoint time boardSize seed currentScore = in ( { initTime = time , initPos = initPos , initDest = initDest - , move initTime initPos initDest time = + , move = \initTime initPos initDest time -> let delta = time - initTime move = (currentLevel currentScore).move initPos initDest delta in initPos `add` move @@ -78,10 +78,15 @@ pointInitPos boardSize seed = pointDestination : Vec2 -> Seed -> (Vec2, Seed) pointDestination boardSize seed = - let ([r1, r2, r3, r4], seed') = generateMany 4 floatGen seed - in ( randomBoardPosition boardSize (r1, r2) (r3, r4) + case generateMany 4 floatGen seed of + ([r1, r2, r3, r4], seed') -> + ( randomBoardPosition boardSize (r1, r2) (r3, r4) , seed' ) + _ -> + ( randomBoardPosition boardSize (0, 0) (0, 0) + , seed + ) generateMany : Int -> Generator a -> Seed -> (List a, Seed) generateMany count gen seed = diff --git a/src/Update/Update.elm b/src/Update/Update.elm index e173aaa..9dc737f 100644 --- a/src/Update/Update.elm +++ b/src/Update/Update.elm @@ -3,8 +3,7 @@ module Update.Update ) where import List -import Keyboard exposing (KeyCode) -import Char exposing (fromCode, toCode) +import Char exposing (fromCode, toCode, KeyCode) import Maybe import Set import Set exposing (Set) @@ -29,22 +28,22 @@ update input game = in if(playerPointsCollision game.time game.player hostilePoints) then { game - | time <- 0 - , currentScore <- 0 - , cloud <- initCloud - , rounds <- (Round game.time game.currentScore) :: game.rounds + | time = 0 + , currentScore = 0 + , cloud = initCloud + , rounds = (Round game.time 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 in { game - | time <- game.time + input.delta - , keysDown <- input.inputKeysDown - , currentScore <- game.currentScore + addScore - , player <- newPlayer - , cloud <- newCloud - , seed <- newSeed + | time = game.time + input.delta + , keysDown = input.inputKeysDown + , currentScore = game.currentScore + addScore + , player = newPlayer + , cloud = newCloud + , seed = newSeed } playerStep : Float -> Vec2 -> Vec2 -> (KeyCode -> Bool) -> Player -> Player |