1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
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 | 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
}
|