diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-11 22:21:06 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-11 22:21:06 +0000 |
commit | edc6b611de752a224082583cd00d19ee6da04c5e (patch) | |
tree | 8e8dbc4d82aba6eb63d9213cb09be3670a7bc3ce /src/Game | |
parent | 2330f10e9ee28cd6389fccf5f01467bedf6c0266 (diff) | |
download | space-plat-hs-edc6b611de752a224082583cd00d19ee6da04c5e.tar.gz space-plat-hs-edc6b611de752a224082583cd00d19ee6da04c5e.zip |
Tidy up, state functions to state module
Diffstat (limited to 'src/Game')
-rw-r--r-- | src/Game/State.hs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/Game/State.hs b/src/Game/State.hs index e05fb61..3773268 100644 --- a/src/Game/State.hs +++ b/src/Game/State.hs @@ -1,4 +1,10 @@ -module Game.State (State (..)) where +module Game.State (State (..), initialState, levelState, maxLives) where + +import Game.Entities.Const (hitDelay) +import qualified Game.Map as M + +maxLives :: Int +maxLives = 4 data State = State { batteries :: Int, @@ -12,3 +18,32 @@ data State = State levelCompleted :: Bool, currentLevel :: Int } + +initialState :: M.Map -> State +initialState m = + State + { batteries = 0, + totalBatteries = M.totalBatteries m, + lives = maxLives, + totalLives = maxLives, + hitDelay = hitDelay, + gameOverDelay = 0, + exit = False, + -- doesn't matter where + lastBattery = (0, 0), + levelCompleted = False, + currentLevel = 0 + } + +levelState :: State -> M.Map -> State +levelState s m = + s + { batteries = 0, + totalBatteries = M.totalBatteries m, + hitDelay = hitDelay, + gameOverDelay = 0, + exit = False, + -- doesn't matter where + lastBattery = (0, 0), + levelCompleted = False + } |