From 1cf6bc1ad9209e4f3f2fcbc129f2577e74e94c99 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 30 Dec 2015 01:03:47 +0100 Subject: Upgrade to elm 0.16.0 --- src/Input.elm | 10 +++------- src/Model/Cloud.elm | 2 +- src/Model/Game.elm | 2 +- src/Model/Level.elm | 22 +++++++++++----------- src/Update/CloudUpdate.elm | 15 ++++++++++----- src/Update/Update.elm | 23 +++++++++++------------ 6 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/Input.elm b/src/Input.elm index 0497107..e18d8be 100644 --- a/src/Input.elm +++ b/src/Input.elm @@ -1,7 +1,7 @@ module Input where -import Char exposing (toCode) -import Keyboard exposing (KeyCode, keysDown, arrows, isDown) +import Char exposing (toCode, KeyCode) +import Keyboard exposing (keysDown, arrows, isDown) import Random import Time exposing (Time, fps) import Signal exposing (..) @@ -18,11 +18,7 @@ type alias Input = getInput : Signal Input getInput = let delta = fps 24 - input = - Input - <~ map recordIntToVec2 arrows - ~ keysDown - ~ delta + input = map3 Input (map recordIntToVec2 arrows) keysDown delta in sampleOn delta input recordIntToVec2 : {x : Int, y : Int} -> Vec2 diff --git a/src/Model/Cloud.elm b/src/Model/Cloud.elm index d279bae..603477b 100644 --- a/src/Model/Cloud.elm +++ b/src/Model/Cloud.elm @@ -22,7 +22,7 @@ type alias Cloud = initCloud : Cloud initCloud = let spawn = 600 - in { points config = + in { points = \config -> case config of White -> [] Black -> [] diff --git a/src/Model/Game.elm b/src/Model/Game.elm index 8769651..24fd400 100644 --- a/src/Model/Game.elm +++ b/src/Model/Game.elm @@ -4,7 +4,7 @@ module Model.Game ) where import Random exposing (..) -import Keyboard exposing (KeyCode) +import Char exposing (KeyCode) import Time exposing (Time) import Set import Set exposing (Set) diff --git a/src/Model/Level.elm b/src/Model/Level.elm index a271653..3fc4258 100644 --- a/src/Model/Level.elm +++ b/src/Model/Level.elm @@ -52,39 +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) + , 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 + , 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) + , 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 + , 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) + , 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 + , 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) + , 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 + , 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) + , 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 + , 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 + , move = \initPos initDest delta -> getWaveMove (delta / 5) (initDest `sub` initPos) 30 30 } 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 -- cgit v1.2.3