Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-libraries
Commits
0adcf9f5
Commit
0adcf9f5
authored
Jan 27, 2000
by
Mike Wiering
Browse files
several names changed: ObjectType -> ObjectCode, SubType -> SubCode, etc.
parent
138d6baf
Changes
14
Hide whitespace changes
Inline
Side-by-side
libraries/ObjectIO/GameLib/GameFunctions.dcl
View file @
0adcf9f5
...
...
@@ -37,7 +37,7 @@ MoveScreenTo :: !Point2 !*OSToolbox -> (!GRESULT, !*OSToolbox)
InitSpriteAnimation
::
!
BID
![(
Int
,
Int
)]
!
Bool
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
InitGameObject
::
!
Object
Typ
e
!
Sub
Typ
e
!
Point2
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
InitGameObject
::
!
Object
Cod
e
!
Sub
Cod
e
!
Point2
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
SetObjectFocus
::
!
Int
!
Int
!
Int
!
Int
!
Int
!
Int
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
...
...
libraries/ObjectIO/GameLib/GameFunctions.icl
View file @
0adcf9f5
...
...
@@ -85,7 +85,7 @@ InitSpriteAnimation :: !BID ![(Int,Int)] !Bool !*OSToolbox -> (!GRESULT, !*OSToo
InitSpriteAnimation
bid
seq
loop
tb
=
OSInitSpriteAnimation
bid
(
TupleListStr
seq
)
loop
tb
InitGameObject
::
!
Object
Typ
e
!
Sub
Typ
e
!
Point2
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
InitGameObject
::
!
Object
Cod
e
!
Sub
Cod
e
!
Point2
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
InitGameObject
ot
st
p
tb
=
OSInitGameObject
ot
st
p
tb
...
...
libraries/ObjectIO/GameLib/Random.dcl
0 → 100644
View file @
0adcf9f5
definition
module
Random
// **************************************************************************************************
//
// General utility for random number generation.
//
// This module has been written in Clean 1.3.2 and uses the Clean Standard Object I/O library 1.2
//
// **************************************************************************************************
import
StdTime
::
RandomSeed
nullRandomSeed
::
RandomSeed
// nullRandomSeed generates a useless RandomSeed (random nullRandomSeed = (0,nullRandomSeed)).
getNewRandomSeed
::
!*
env
->
(!
RandomSeed
,
!*
env
)
|
TimeEnv
env
// GetNewRandomSeed generates a useful RandomSeed, using the current time.
random
::
!
RandomSeed
->
(!
Int
,
!
RandomSeed
)
// Given a RandomSeed, Random generates a random number and a new RandomSeed.
libraries/ObjectIO/GameLib/Random.icl
0 → 100644
View file @
0adcf9f5
implementation
module
Random
import
StdInt
,
StdClass
from
StdTime
import
getCurrentTime
,
Time
::
RandomSeed
:==
Int
nullRandomSeed
::
RandomSeed
nullRandomSeed
=
0
getNewRandomSeed
::
!*
env
->
(!
RandomSeed
,
!*
env
)
|
TimeEnv
env
getNewRandomSeed
env
#
({
hours
,
minutes
,
seconds
},
env
)
=
getCurrentTime
env
=
(
1
+(
hours
+
minutes
+
seconds
)
bitand
65535
,
env
)
random
::
!
RandomSeed
->
(!
Int
,!
RandomSeed
)
random
seed
=
(
newSeed
,
newSeed
)
where
newSeed
=
if
(
nextSeed
>=
0
)
nextSeed
(
nextSeed
+65537
)
nextSeed
=
(
seed75
bitand
65535
)-(
seed75
>>
16
)
seed75
=
seed
*
75
libraries/ObjectIO/GameLib/StdGame.dcl
View file @
0adcf9f5
...
...
@@ -25,14 +25,16 @@ BND_STATIC_BOUNDS :== 1 << 31
SK_FOREVER
:==
-1
startGame
::
.(
Game
a
)
a
[.
GameAttribute
a
]
!*
World
->
.
World
openGame
::
.
gs
!(
Game
.
gs
)
![
GameAttribute
.
gs
]
!(
PSt
.
l
)
->
(!
ErrorReport
,!
PSt
.
l
)
->
(
.
gs
,
!
ErrorReport
,!
PSt
.
l
)
createGameBitmap
::
!
GameBitmap
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createAnimation
::
!
Sprite
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createNewGameObject
::
!
Object
Typ
e
!
Sub
Typ
e
!
Point2
!(
GSt
.
gs
)
createNewGameObject
::
!
Object
Cod
e
!
Sub
Cod
e
!
Point2
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
::
ObjectFocus
...
...
@@ -52,11 +54,11 @@ createObjectFocus :: !ObjectFocus !(GSt .gs) -> (!GRESULT, !GSt .gs)
=
Self
|
AllObjects
|
BoundType
Bounds
// modified 01/11/99
createUserGameEvent
::
!
Event
Typ
e
createUserGameEvent
::
!
Event
Cod
e
!
EventPar
!
EventPar
!
EventTarget
!
Sub
Typ
e
!
Sub
Cod
e
!
GameTime
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
...
...
@@ -94,10 +96,10 @@ setBoundMap :: !Int !Int !(!Int, !DirectionSet) !(GSt .gs)
->
(!
GRESULT
,
!
GSt
.
gs
)
defaultInitObject
::
Size
state
Sub
Typ
e
Point2
GameTime
defaultInitObject
::
Size
state
Sub
Cod
e
Point2
GameTime
!*(
GSt
.
gs
)
->
GameObjectState
state
*(
GSt
.
gs
)
defaultGameObject
::
!
Object
Typ
e
!
Size
state
->
GameObject
*(
GSt
.
gs
)
defaultObjectRec
::
Sub
Typ
e
Point2
Size
GameTime
defaultGameObject
::
!
Object
Cod
e
!
Size
state
->
GameObject
*(
GSt
.
gs
)
defaultObjectRec
::
Sub
Cod
e
Point2
Size
GameTime
!*(
GSt
.
gs
)
->
(!
GameObjectRec
,!*
GSt
.
gs
)
blankScreen
::
Level
(
GSt
.
gs
)
...
...
libraries/ObjectIO/GameLib/StdGame.icl
View file @
0adcf9f5
implementation
module
StdGame
import
StdProcess
import
StdArray
,
StdBool
,
StdClass
,
StdFunc
,
StdInt
,
StdList
,
StdMisc
import
StdId
import
fixed
,
GameFunctions
,
gamehandle
,
gameutils
,
gst
...
...
@@ -20,7 +21,16 @@ BND_STATIC_BOUNDS :== 1 << 31
SK_FOREVER
:==
-1
openGame
::
.
gs
!(
Game
.
gs
)
![
GameAttribute
.
gs
]
!(
PSt
.
l
)
->
(!
ErrorReport
,
!
PSt
.
l
)
startGame
::
.(
Game
a
)
a
[.
GameAttribute
a
]
!*
World
->
.
World
startGame
gamedef
initialstate
options
world
=
startIO
SDI
0
init
[
ProcessClose
closeProcess
]
world
where
init
ps
#
(
finalstate
,
_,
ps
)
=
openGame
initialstate
gamedef
options
ps
=
closeProcess
ps
openGame
::
.
gs
!(
Game
.
gs
)
![
GameAttribute
.
gs
]
!(
PSt
.
l
)
->
(.
gs
,
!
ErrorReport
,
!
PSt
.
l
)
openGame
gs
gdef
attr
ps
#
(
wId
,
ps
)
=
accPIO
openId
ps
#
size
=
findSize
attr
{
w
=
320
,
h
=
240
}
...
...
@@ -30,9 +40,9 @@ openGame gs gdef attr ps
#
gst
=
toGSt
gs
tb
#
(
initLevel
,
gst
)
=
gdef
.
nextlevel
gst
#
(
gs
,
tb
)
=
fromGSt
gst
#
(_,
tb
)
=
PlayLevels
initLevel
gs
gdef
tb
#
(
gs
,
_,
tb
)
=
PlayLevels
initLevel
gs
gdef
tb
#
ps
=
appPIO
(
setIOToolbox
tb
)
ps
=
(
NoError
,
ps
)
=
(
gs
,
NoError
,
ps
)
where
findSize
::
![
GameAttribute
.
gs
]
!
Size
->
Size
findSize
[]
s
=
s
...
...
@@ -67,10 +77,10 @@ where
#
pState
=
appPIO
decreaseWindowBound
pState
=
(
NoError
,
pState
)
PlayLevels
::
!
Int
.
gs
!(
Game
.
gs
)
!*
OSToolbox
->
(!
ErrorReport
,
!*
OSToolbox
)
PlayLevels
::
!
Int
.
gs
!(
Game
.
gs
)
!*
OSToolbox
->
(
.
gs
,
!
ErrorReport
,
!*
OSToolbox
)
PlayLevels
level
gs
gdef
tb
|
level
==
0
=
(
NoError
,
tb
)
=
(
gs
,
NoError
,
tb
)
#
ghnd
=
createGameHandle
gdef
#
(_,
gs
,
tb
)
=
PlayLevel
level
gs
ghnd
tb
#
gst
=
toGSt
gs
tb
...
...
@@ -227,7 +237,7 @@ createAnimation sprite=:{bitmap, sequence, loop} gst
#
(
sprid
,
gst
)
=
accGStTb
(
InitSpriteAnimation
bid
sequence
loop
)
gst
=
(
0
-
sprid
,
gst
)
createNewGameObject
::
!
Object
Typ
e
!
Sub
Typ
e
!
Point2
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createNewGameObject
::
!
Object
Cod
e
!
Sub
Cod
e
!
Point2
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createNewGameObject
ot
st
p
gst
=
accGStTb
(
InitGameObject
ot
st
p
)
gst
...
...
@@ -286,7 +296,7 @@ EventTargetToInt AllObjects = -1
EventTargetToInt
(
BoundType
b
)
=
b
// modified 01/11/99
createUserGameEvent
::
!
Event
Typ
e
!
EventPar
!
EventPar
!
EventTarget
!
Sub
Typ
e
!
GameTime
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createUserGameEvent
::
!
Event
Cod
e
!
EventPar
!
EventPar
!
EventTarget
!
Sub
Cod
e
!
GameTime
!(
GSt
.
gs
)
->
(!
GRESULT
,
!
GSt
.
gs
)
createUserGameEvent
ev
evpar1
evpar2
dest
subdest
time
gst
=
accGStTb
(
CreateUserEvent
ev
evpar1
evpar2
(
EventTargetToInt
dest
)
subdest
time
)
gst
...
...
@@ -324,10 +334,10 @@ defaultObjectOptions
,
removemapcode
=
False
}
defaultObjectRec
::
Sub
Typ
e
Point2
Size
GameTime
!*(
GSt
.
gs
)
->
(!
GameObjectRec
,!*
GSt
.
gs
)
defaultObjectRec
objsub
typ
e
position
size
time
gs
defaultObjectRec
::
Sub
Cod
e
Point2
Size
GameTime
!*(
GSt
.
gs
)
->
(!
GameObjectRec
,!*
GSt
.
gs
)
defaultObjectRec
objsub
cod
e
position
size
time
gs
=
(
{
active
=
True
,
sub
typ
e
=
objsub
typ
e
,
sub
cod
e
=
objsub
cod
e
,
size
=
size
,
pos
=
position
,
offset
=
zero
...
...
@@ -353,17 +363,17 @@ defaultObjectRec objsubtype position size time gs
}
,
gs
)
defaultInitObject
::
Size
state
Sub
Typ
e
Point2
GameTime
!*(
GSt
.
gs
)
->
GameObjectState
state
*(
GSt
.
gs
)
defaultInitObject
::
Size
state
Sub
Cod
e
Point2
GameTime
!*(
GSt
.
gs
)
->
GameObjectState
state
*(
GSt
.
gs
)
defaultInitObject
size
state
subtype
pos
time
gs
#
(
newobjrec
,
gs
)
=
defaultObjectRec
subtype
pos
size
time
gs
=
{
objectstate
=
state
,
gamestate
=
gs
,
objectrec
=
newobjrec
}
=
{
st
=
state
,
gs
=
gs
,
or
=
newobjrec
}
defaultGameObject
::
!
Object
Typ
e
!
Size
state
->
GameObject
*(
GSt
.
gs
)
defaultGameObject
obj
typ
e
size
state
=
{
object
typ
e
=
obj
typ
e
defaultGameObject
::
!
Object
Cod
e
!
Size
state
->
GameObject
*(
GSt
.
gs
)
defaultGameObject
obj
cod
e
size
state
=
{
object
cod
e
=
obj
cod
e
,
sprites
=
[]
,
init
=
defaultInitObject
size
state
,
done
=
\{
g
amestate
}
->
gamestate
,
done
=
\{
g
s
}
->
gs
,
move
=
id
,
animation
=
id
,
touchbound
=
\_
_
->
id
...
...
libraries/ObjectIO/GameLib/StdGameDef.dcl
View file @
0adcf9f5
definition
module
StdGameDef
// ********************************************************************************
// Clean Standard Game library, version 1.2
//
...
...
@@ -13,11 +12,9 @@ from StdOverloaded import zero
from
StdString
import
String
from
StdIOBasic
import
Point2
,
Size
,
IdFun
from
StdMaybe
import
Maybe
,
Just
,
Nothing
from
StdPictureDef
import
Colour
,
RGB
,
RGBColour
,
Black
,
White
,
DarkGrey
,
Grey
,
LightGrey
,
Red
,
Green
,
Blue
,
Cyan
,
Magenta
,
Yellow
from
StdPictureDef
import
Colour
,
RGB
,
RGBColour
,
Black
,
White
,
DarkGrey
,
Grey
,
LightGrey
,
Red
,
Green
,
Blue
,
Cyan
,
Magenta
,
Yellow
import
StdGSt
...
...
@@ -29,7 +26,7 @@ import StdGSt
=
{
levels
::
[
Level
(
GSt
gs
)]
// levels
,
quitlevel
::
St
(
GSt
gs
)
Bool
// True quits the game
,
nextlevel
::
St
(
GSt
gs
)
Int
// new level if >0 (0 quits)
,
statistics
::
St
(
GSt
gs
)
[
GameText
]
// all game text items
,
textitems
::
St
(
GSt
gs
)
[
GameText
]
// all game text items
}
::
Level
state
...
...
@@ -111,10 +108,10 @@ import StdGSt
// (n = # blocks in gamebitmap; m = # sequences)
::
TileSequence
:==
(!
Int
,
Sequence
)
:==
(!
Int
,
Sequence
)
// block sequence number, Sequence
::
Sequence
:==
[(
Int
,
Int
)]
:==
[(
Int
,
Int
)]
// tile number, duration
::
Movement
:==
Point2
GameTime
->
Point2
// calculate layer's position from game position
...
...
@@ -127,33 +124,36 @@ import StdGSt
,
sequence
::
!
Sequence
// seqence of blocks
,
loop
::
!
Bool
// if FALSE, callback animation function
}
::
GameObject
gs
=
E
.
state
:
{
object
typ
e
::
!
Object
Typ
e
//
identifier
for object type (0 AutoInitObject)
{
object
cod
e
::
!
Object
Cod
e
//
code
for object type (0 AutoInitObject)
,
sprites
::
![
Sprite
]
// sprite 1..n
,
init
::
!
Sub
Typ
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
init
::
!
Sub
Cod
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
done
::
!(
GameObjectState
state
gs
)
->
gs
,
move
::
!
ObjectFun
state
gs
,
animation
::
!
ObjectFun
state
gs
,
touchbound
::
!
DirectionSet
MapCode
->
ObjectFun
state
gs
,
collide
::
!
DirectionSet
Object
Typ
e
GameObjectRec
->
ObjectFun
state
gs
,
collide
::
!
DirectionSet
Object
Cod
e
GameObjectRec
->
ObjectFun
state
gs
,
frametimer
::
!
ObjectFun
state
gs
,
keydown
::
!
KeyCode
->
ObjectFun
state
gs
,
keyup
::
!
KeyCode
->
ObjectFun
state
gs
,
userevent
::
!
Event
Typ
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
,
userevent
::
!
Event
Cod
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
}
::
*
GameObjectState
state
gs
=
{
objectstate
::
state
,
gamestate
::
gs
,
objectrec
::
GameObjectRec
=
{
st
::
state
// object
state
,
or
::
GameObjectRec
// object record
,
gs
::
gs
// game state
}
::
ObjectFun
state
gs
:==
IdFun
(
GameObjectState
state
gs
)
::
Object
Typ
e
::
Object
Cod
e
:==
Int
::
Sub
Typ
e
::
Sub
Cod
e
:==
Int
::
MapCode
...
...
@@ -162,7 +162,7 @@ import StdGSt
::
KeyCode
:==
Int
::
Event
Typ
e
::
Event
Cod
e
:==
Int
::
EventPar
...
...
@@ -184,7 +184,7 @@ import StdGSt
::
GameObjectRec
=
{
active
::
!
Bool
// move and check collisions?
,
sub
typ
e
::
!
Sub
Typ
e
// object's sub
typ
e
,
sub
cod
e
::
!
Sub
Cod
e
// object's sub
-cod
e
,
size
::
!
Size
// the actual size
,
pos
::
!
Point2
// current position
,
offset
::
!
Point2
// relative offset for sprite
...
...
libraries/ObjectIO/GameLib/StdGameDef.icl
View file @
0adcf9f5
...
...
@@ -7,17 +7,14 @@ implementation module StdGameDef
// StdGameDef contains all the type definitions needed to specify a game.
// ********************************************************************************
from
StdFunc
import
St
from
StdOverloaded
import
zero
from
StdString
import
String
from
StdIOBasic
import
Point2
,
Size
,
IdFun
from
StdMaybe
import
Maybe
,
Just
,
Nothing
from
StdPictureDef
import
Colour
,
RGB
,
RGBColour
,
Black
,
White
,
DarkGrey
,
Grey
,
LightGrey
,
Red
,
Green
,
Blue
,
Cyan
,
Magenta
,
Yellow
from
StdPictureDef
import
Colour
,
RGB
,
RGBColour
,
Black
,
White
,
DarkGrey
,
Grey
,
LightGrey
,
Red
,
Green
,
Blue
,
Cyan
,
Magenta
,
Yellow
import
StdGSt
::
GameAttribute
gs
...
...
@@ -28,7 +25,7 @@ import StdGSt
=
{
levels
::
[
Level
(
GSt
gs
)]
// levels
,
quitlevel
::
St
(
GSt
gs
)
Bool
// True quits the game
,
nextlevel
::
St
(
GSt
gs
)
Int
// new level if >0 (0 quits)
,
statistics
::
St
(
GSt
gs
)
[
GameText
]
// all text items
,
textitems
::
St
(
GSt
gs
)
[
GameText
]
// all text items
}
::
Level
state
...
...
@@ -93,7 +90,7 @@ import StdGSt
}
::
GameTime
:==
Int
// time in frames
:==
Int
// time in frames
::
GameBitmap
=
{
bitmapname
::
!
String
// bitmap that contains smaller blocks
...
...
@@ -110,10 +107,10 @@ import StdGSt
// (n = # blocks in gamebitmap; m = # sequences)
::
TileSequence
:==
(!
Int
,
Sequence
)
:==
(!
Int
,
Sequence
)
// block sequence number, Sequence
::
Sequence
:==
[(
Int
,
Int
)]
:==
[(
Int
,
Int
)]
// tile number, duration
::
Movement
:==
Point2
GameTime
->
Point2
// calculate layer's position from game position
...
...
@@ -129,31 +126,33 @@ import StdGSt
::
GameObject
gs
=
E
.
state
:
{
object
typ
e
::
!
Object
Typ
e
//
identifier
for object type (0 AutoInitObject)
{
object
cod
e
::
!
Object
Cod
e
//
code
for object type (0 AutoInitObject)
,
sprites
::
![
Sprite
]
// sprite 1..n
,
init
::
!
Sub
Typ
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
init
::
!
Sub
Cod
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
done
::
!(
GameObjectState
state
gs
)
->
gs
,
move
::
!
ObjectFun
state
gs
,
animation
::
!
ObjectFun
state
gs
,
touchbound
::
!
DirectionSet
MapCode
->
ObjectFun
state
gs
,
collide
::
!
DirectionSet
Object
Typ
e
GameObjectRec
->
ObjectFun
state
gs
,
collide
::
!
DirectionSet
Object
Cod
e
GameObjectRec
->
ObjectFun
state
gs
,
frametimer
::
!
ObjectFun
state
gs
,
keydown
::
!
KeyCode
->
ObjectFun
state
gs
,
keyup
::
!
KeyCode
->
ObjectFun
state
gs
,
userevent
::
!
Event
Typ
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
,
userevent
::
!
Event
Cod
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
}
::
*
GameObjectState
state
gs
=
{
objectstate
::
state
,
gamestate
::
gs
,
objectrec
::
GameObjectRec
=
{
st
::
state
// object
state
,
or
::
GameObjectRec
// object record
,
gs
::
gs
// game state
}
::
ObjectFun
state
gs
:==
IdFun
(
GameObjectState
state
gs
)
::
Object
Typ
e
::
Object
Cod
e
:==
Int
::
Sub
Typ
e
::
Sub
Cod
e
:==
Int
::
MapCode
...
...
@@ -162,7 +161,7 @@ import StdGSt
::
KeyCode
:==
Int
::
Event
Typ
e
::
Event
Cod
e
:==
Int
::
EventPar
...
...
@@ -184,7 +183,7 @@ import StdGSt
::
GameObjectRec
=
{
active
::
!
Bool
// move and check collisions?
,
sub
typ
e
::
!
Sub
Typ
e
// object's sub
typ
e
,
sub
cod
e
::
!
Sub
Cod
e
// object's sub
cod
e
,
size
::
!
Size
// the actual size
,
pos
::
!
Point2
// current position
,
offset
::
!
Point2
// relative offset for sprite
...
...
libraries/ObjectIO/GameLib/gamehandle.dcl
View file @
0adcf9f5
...
...
@@ -5,10 +5,10 @@ definition module gamehandle
import
StdGameDef
::
GameHandle
gs
=
{
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
,
statistic
s`
::
!
St
(
GSt
gs
)
[
GameText
]
// all text items
=
{
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
,
textitem
s`
::
!
St
(
GSt
gs
)
[
GameText
]
// all text items
}
::
LevelHandle
state
...
...
@@ -23,20 +23,20 @@ import StdGameDef
::
GameObjectHandle
gs
=
E
.
state
:
{
object
typ
e`
::
!
Object
Typ
e
{
object
cod
e`
::
!
Object
Cod
e
,
sprites`
::
![
Sprite
]
,
spriteids`
::
![
SpriteID
]
,
instances`
::
![(
InstanceID
,
state
)]
,
init`
::
!
Sub
Typ
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
init`
::
!
Sub
Cod
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
done`
::
!(
GameObjectState
state
gs
)
->
gs
,
move`
::
!
ObjectFun
state
gs
,
animation`
::
!
ObjectFun
state
gs
,
touchbound`
::
!
DirectionSet
MapCode
->
ObjectFun
state
gs
,
collide`
::
!
DirectionSet
Object
Typ
e
GameObjectRec
->
ObjectFun
state
gs
,
collide`
::
!
DirectionSet
Object
Cod
e
GameObjectRec
->
ObjectFun
state
gs
,
frametimer`
::
!
ObjectFun
state
gs
,
keydown`
::
!
KeyCode
->
ObjectFun
state
gs
,
keyup`
::
!
KeyCode
->
ObjectFun
state
gs
,
userevent`
::
!
Event
Typ
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
,
userevent`
::
!
Event
Cod
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
}
::
InstanceID
...
...
libraries/ObjectIO/GameLib/gamehandle.icl
View file @
0adcf9f5
...
...
@@ -6,10 +6,10 @@ from StdList import map
import
StdGameDef
::
GameHandle
gs
=
{
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
,
statistic
s`
::
!
St
(
GSt
gs
)
[
GameText
]
// all text items
=
{
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
,
textitem
s`
::
!
St
(
GSt
gs
)
[
GameText
]
// all text items
}
::
LevelHandle
state
...
...
@@ -24,20 +24,20 @@ import StdGameDef
::
GameObjectHandle
gs
=
E
.
state
:
{
object
typ
e`
::
!
Object
Typ
e
{
object
cod
e`
::
!
Object
Cod
e
,
sprites`
::
![
Sprite
]
,
spriteids`
::
![
SpriteID
]
,
instances`
::
![(
InstanceID
,
state
)]
,
init`
::
!
Sub
Typ
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
init`
::
!
Sub
Cod
e
!
Point2
!
GameTime
!
gs
->
GameObjectState
state
gs
,
done`
::
!(
GameObjectState
state
gs
)
->
gs
,
move`
::
!
ObjectFun
state
gs
,
animation`
::
!
ObjectFun
state
gs
,
touchbound`
::
!
DirectionSet
MapCode
->
ObjectFun
state
gs
,
collide`
::
!
DirectionSet
Object
Typ
e
GameObjectRec
->
ObjectFun
state
gs
,
collide`
::
!
DirectionSet
Object
Cod
e
GameObjectRec
->
ObjectFun
state
gs
,
frametimer`
::
!
ObjectFun
state
gs
,
keydown`
::
!
KeyCode
->
ObjectFun
state
gs
,
keyup`
::
!
KeyCode
->
ObjectFun
state
gs
,
userevent`
::
!
Event
Typ
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
,
userevent`
::
!
Event
Cod
e
!
EventPar
!
EventPar
->
ObjectFun
state
gs
}
::
InstanceID
...
...
@@ -46,9 +46,9 @@ import StdGameDef
createObjectHandle
::
!(
GameObject
.
gs
)
->
GameObjectHandle
.
gs
createObjectHandle
{
object
typ
e
,
sprites
,
init
,
done
,
move
,
animation
,
touchbound
,
createObjectHandle
{
object
cod
e
,
sprites
,
init
,
done
,
move
,
animation
,
touchbound
,
collide
,
frametimer
,
keydown
,
keyup
,
userevent
}
=
{
object
typ
e`
=
object
typ
e
=
{
object
cod
e`
=
object
cod
e
,
sprites`
=
sprites
,
spriteids`
=
[]
,
instances`
=
[]
...
...
@@ -76,9 +76,9 @@ createLevelHandle {boundmap, initpos, layers, objects, music, soundsamples, leve
}
createGameHandle
::
!(
Game
.
gs
)
->
GameHandle
.
gs
createGameHandle
{
levels
,
quitlevel
,
nextlevel
,
statistic
s
}
createGameHandle
{
levels
,
quitlevel
,
nextlevel
,
textitem
s
}
=
{
levels`
=
map
createLevelHandle
levels
,
quitlevel`
=
quitlevel
,
nextlevel`
=
nextlevel
,
statistic
s`
=
statistic
s
,
textitem
s`
=
textitem
s
}
libraries/ObjectIO/GameLib/gameobjectutils.dcl
View file @
0adcf9f5
...
...
@@ -13,13 +13,13 @@ CompressBools :: !(!Bool, !Bool, !Bool, !Bool, !Bool, !Bool, !Bool, !Bool) -> In
toInt01
::
!
Bool
->
Int
// store an GameObjectRec in the game engine
SetObjectRec
::
!
InstanceID
!
Object
Typ
e
!
GameObjectRec
![
SpriteID
]
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
SetObjectRec
::
!
InstanceID
!
Object
Cod
e
!
GameObjectRec
![
SpriteID
]
!*
OSToolbox
->
(!
GRESULT
,
!*
OSToolbox
)
// load an GameObjectRec from the game engine
GetObjectRec
::
!
Int
!*
OSToolbox
->
(!
GRESULT
,
!
Object
Typ
e
,
!
GameObjectRec
,
!*
OSToolbox
)
GetObjectRec
::
!
Int
!*
OSToolbox
->
(!
GRESULT
,
!
Object
Cod
e
,
!
GameObjectRec
,
!*
OSToolbox
)
// get the definition of an object by it's ObjectType
getobject
::
!
Object
Typ
e
!(
GameHandle
.
gs
)
->
Maybe
(
GameObjectHandle
(
GSt
.
gs
))
getobject
::
!
Object
Cod
e
!(
GameHandle
.
gs
)
->
Maybe
(
GameObjectHandle
(
GSt
.
gs
))
// store the definition of an object in the game definition
putobject
::
!(
GameObjectHandle
(
GSt
.
gs
))
!(
GameHandle
.
gs
)
->
GameHandle
.
gs
...
...
@@ -36,6 +36,8 @@ removeinstance :: a ![(a,b)] -> [(a,b)] | ==a