Commit 1cf6bc1a authored by Joris's avatar Joris

Upgrade to elm 0.16.0

parent 79a9db1c
......@@ -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
```
......@@ -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"
}
}
{
"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",
......
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
......
......@@ -22,7 +22,7 @@ type alias Cloud =
initCloud : Cloud
initCloud =
let spawn = 600
in { points config =
in { points = \config ->
case config of
White -> []
Black -> []
......
......@@ -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)
......
......@@ -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
}
......@@ -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 =
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment