diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | elm-package.json | 6 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | src/Input.elm | 10 | ||||
-rw-r--r-- | src/Model/Cloud.elm | 2 | ||||
-rw-r--r-- | src/Model/Game.elm | 2 | ||||
-rw-r--r-- | src/Model/Level.elm | 22 | ||||
-rw-r--r-- | src/Update/CloudUpdate.elm | 15 | ||||
-rw-r--r-- | src/Update/Update.elm | 23 |
9 files changed, 44 insertions, 46 deletions
@@ -10,12 +10,8 @@ You can play at [http://guyonvarch.github.io/catchvoid](http://guyonvarch.github Usage ----- -Install the elm platform: http://elm-lang.org/Install.elm - -Launch the following commands: - ```bash -elm package install npm install +npm run install-elm npm start ``` diff --git a/elm-package.json b/elm-package.json index 839ed41..8f4f61e 100644 --- a/elm-package.json +++ b/elm-package.json @@ -7,8 +7,8 @@ "exposed-modules": [], "elm-version": "0.15.1 <= v < 0.16.0", "dependencies": { - "elm-lang/core": "2.1.0 <= v < 3.0.0", - "evancz/elm-html": "4.0.1 <= v < 5.0.0", - "evancz/elm-svg": "2.0.0 <= v < 3.0.0" + "elm-lang/core": "3.0.0 <= v < 4.0.0", + "evancz/elm-html": "4.0.2 <= v < 5.0.0", + "evancz/elm-svg": "2.0.1 <= v < 3.0.0" } } diff --git a/package.json b/package.json index 35d033a..21cec49 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,11 @@ { "devDependencies": { "watch": "0.16.0", - "http-server": "0.8.5" + "http-server": "0.8.5", + "elm": "0.16.0" }, "scripts": { + "install-elm": "elm package install", "start": "npm run watch", "watch": "npm run launch-server & watch 'npm run build --silent' 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 |