module Game.State (State (..), initialState, levelState, maxLives, PlayState (..)) where import Game.Entities.Const (hitDelay) import qualified Game.Map as M maxLives :: Int maxLives = 4 data PlayState = InPlay | IntoStage | ExitStarted | ExitDone Int | GameOver deriving (Eq) data State = State { batteries :: Int, totalBatteries :: Int, lives :: Int, totalLives :: Int, hitDelay :: Int, gameOverDelay :: Int, exit :: Bool, lastBattery :: (Int, Int), playState :: PlayState, 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), playState = IntoStage, 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), playState = IntoStage }