diff options
author | Joris Guyonvarch | 2015-03-07 12:20:27 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-07 12:20:27 +0100 |
commit | 336816d2e8ab4afff1562123dfde61bf3a68e61c (patch) | |
tree | 698d8b8c70ba1ee1ddb895dfcd3b2322f6860794 | |
parent | 8f8df67f3795b02c6918d7df832580e9de7d0802 (diff) |
Save player config when relaunching game
-rw-r--r-- | src/Game.elm | 6 | ||||
-rw-r--r-- | src/Main.elm | 3 | ||||
-rw-r--r-- | src/Step.elm | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/Game.elm b/src/Game.elm index 4d68219..e294942 100644 --- a/src/Game.elm +++ b/src/Game.elm @@ -18,15 +18,15 @@ type alias Game = , seed : Seed } -initialGame : Seed -> Vec2 -> Int -> Game -initialGame seed playerPos bestScore = +initialGame : Seed -> Vec2 -> Config -> Int -> Game +initialGame seed playerPos config bestScore = let initPlayer = { pos = playerPos , speed = { x = 0 , y = 0 } - , config = White + , config = config } in { time = 0 diff --git a/src/Main.elm b/src/Main.elm index 9286ed9..6be5766 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -10,12 +10,13 @@ import Display (display) import Step (step) import Input (getInput) import Vec2 (originVec) +import Config (Config(White)) main : Signal Html main = Signal.map display game game : Signal Game -game = Signal.foldp step (initialGame initialSeed originVec 0) getInput +game = Signal.foldp step (initialGame initialSeed originVec White 0) getInput port initialTime : Int diff --git a/src/Step.elm b/src/Step.elm index e2b7fa7..dd340a5 100644 --- a/src/Step.elm +++ b/src/Step.elm @@ -21,7 +21,7 @@ step {dir, inputKeysDown, delta} {time, keysDown, score, player, cloud, bestScor let hostilePoints = cloud.points (otherConfig player.config) in if(playerPointsCollision time player hostilePoints) then let newBestScore = if(score > bestScore) then score else bestScore - in initialGame seed player.pos newBestScore + in initialGame seed player.pos player.config newBestScore else let newTime = time + delta newPlayer = playerStep delta dir (newKeyCode keysDown inputKeysDown) player |