Commit 336816d2 authored by Joris Guyonvarch's avatar Joris Guyonvarch

Save player config when relaunching game

parent 8f8df67f
...@@ -18,15 +18,15 @@ type alias Game = ...@@ -18,15 +18,15 @@ type alias Game =
, seed : Seed , seed : Seed
} }
initialGame : Seed -> Vec2 -> Int -> Game initialGame : Seed -> Vec2 -> Config -> Int -> Game
initialGame seed playerPos bestScore = initialGame seed playerPos config bestScore =
let initPlayer = let initPlayer =
{ pos = playerPos { pos = playerPos
, speed = , speed =
{ x = 0 { x = 0
, y = 0 , y = 0
} }
, config = White , config = config
} }
in in
{ time = 0 { time = 0
......
...@@ -10,12 +10,13 @@ import Display (display) ...@@ -10,12 +10,13 @@ import Display (display)
import Step (step) import Step (step)
import Input (getInput) import Input (getInput)
import Vec2 (originVec) import Vec2 (originVec)
import Config (Config(White))
main : Signal Html main : Signal Html
main = Signal.map display game main = Signal.map display game
game : Signal 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 port initialTime : Int
......
...@@ -21,7 +21,7 @@ step {dir, inputKeysDown, delta} {time, keysDown, score, player, cloud, bestScor ...@@ -21,7 +21,7 @@ step {dir, inputKeysDown, delta} {time, keysDown, score, player, cloud, bestScor
let hostilePoints = cloud.points (otherConfig player.config) let hostilePoints = cloud.points (otherConfig player.config)
in if(playerPointsCollision time player hostilePoints) then in if(playerPointsCollision time player hostilePoints) then
let newBestScore = if(score > bestScore) then score else bestScore let newBestScore = if(score > bestScore) then score else bestScore
in initialGame seed player.pos newBestScore in initialGame seed player.pos player.config newBestScore
else else
let newTime = time + delta let newTime = time + delta
newPlayer = playerStep delta dir (newKeyCode keysDown inputKeysDown) player newPlayer = playerStep delta dir (newKeyCode keysDown inputKeysDown) 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