gamehandle.dcl 2.13 KB
Newer Older
Peter Achten's avatar
Peter Achten committed
1
2
3
4
5
6
7
definition module gamehandle

//  this module defines the internal representation of a game

import StdGameDef

:: GameHandle gs
8
9
10
11
   = { levels`    :: ![LevelHandle (GSt gs)]       // levels
     , quitlevel` :: !St (GSt gs) Bool             // when true, the game engine quits
     , nextlevel` :: !St (GSt gs) Int              // 1,2,... level in list, 0 = exit
     , textitems` :: !St (GSt gs) [GameText]       // all text items
Peter Achten's avatar
Peter Achten committed
12
13
14
     }

:: LevelHandle state
15
16
17
18
19
20
21
   = { boundmap`      :: !BoundMap                   // map of all static bounds in a level
     , initpos`       :: !Point2                     // center of screen in boundmap
     , layers`        :: ![Layer]                    // all layers [back..front]
     , objects`       :: ![GameObjectHandle state]   // all other objects in the level
     , music`         :: !Maybe Music                // background music
     , soundsamples`  :: ![SoundSample]
     , leveloptions`  :: !LevelOptions
Peter Achten's avatar
Peter Achten committed
22
23
     }

24
25
:: GameObjectHandle gs
   = E. state:
26
     { objectcode` :: !ObjectCode
27
28
29
     , sprites`    :: ![Sprite]
     , spriteids`  :: ![SpriteID]
     , instances`  :: ![(InstanceID, state)]
30
     , init`       :: !SubCode !Point2 !GameTime !gs         -> GameObjectState state gs
31
32
33
34
     , done`       :: !(GameObjectState state gs)            -> gs
     , move`       :: !                                         ObjectFun state gs
     , animation`  :: !                                         ObjectFun state gs
     , touchbound` :: !DirectionSet MapCode                  -> ObjectFun state gs
35
     , collide`    :: !DirectionSet ObjectCode GameObjectRec -> ObjectFun state gs
36
37
38
     , frametimer` :: !                                         ObjectFun state gs
     , keydown`    :: !KeyCode                               -> ObjectFun state gs
     , keyup`      :: !KeyCode                               -> ObjectFun state gs
39
     , userevent`  :: !EventCode !EventPar !EventPar         -> ObjectFun state gs
Peter Achten's avatar
Peter Achten committed
40
41
42
43
44
     }

:: InstanceID
   :== Int

45
createObjectHandle :: !(GameObject .gs) -> GameObjectHandle .gs
Peter Achten's avatar
Peter Achten committed
46

47
createLevelHandle  :: !(Level .gs)      -> LevelHandle .gs
Peter Achten's avatar
Peter Achten committed
48

49
createGameHandle   :: !(Game .gs)       -> GameHandle .gs