Commit 8d976905 authored by Mike Wiering's avatar Mike Wiering
Browse files

Game Examples now use Tile Studio instead of GRED/EDLEV

parent b59a0b2c
...@@ -3,14 +3,16 @@ module Worms ...@@ -3,14 +3,16 @@ module Worms
/* /*
Worms Demonstration Game for the Clean Game Library Worms Demonstration Game for the Clean Game Library
Version: 2.0 Version: 3.0 (March 20, 2000)
Author: Mike Wiering (mike.wiering@cs.kun.nl) Author: Mike Wiering (mike.wiering@cs.kun.nl)
Note: To play Worms with background music, copy your favourite MIDI file
to Worms.mid in the music\ subdirectory.
*/ */
import StdEnv, StdIO import StdEnv, StdIO, StdGameDef, StdGame, StdGSt, GameFunctions, Random, notes
import StdGameDef, StdGame, StdGSt, GameFunctions
import L1, L2, L3, WORM, HEAD import WormsGfx /* generated by Tile Studio */
import Random, notes
:: GameState :: GameState
= { curlevel :: !Int = { curlevel :: !Int
...@@ -32,6 +34,7 @@ initialGameState = { curlevel = 0 ...@@ -32,6 +34,7 @@ initialGameState = { curlevel = 0
} }
/* move with speed V */ /* move with speed V */
V = 3.0 /* 24 rem V must be 0 */ V = 3.0 /* 24 rem V must be 0 */
/* ---------- main program: load game definition and start the game! ---------- */ /* ---------- main program: load game definition and start the game! ---------- */
...@@ -40,8 +43,7 @@ Start :: *World -> *World ...@@ -40,8 +43,7 @@ Start :: *World -> *World
Start world Start world
# (seed, world) = getNewRandomSeed world # (seed, world) = getNewRandomSeed world
= startGame WormsDemo {initialGameState & randseed = seed} = startGame WormsDemo {initialGameState & randseed = seed}
[ScreenSize {w = 640, h = 480}, ColorDepth 16] world [ScreenSize {w = 640, h = 480}, ColorDepth 16] world
/* ---------- the complete game definition ---------- */ /* ---------- the complete game definition ---------- */
...@@ -60,14 +62,12 @@ WormsDemo = ...@@ -60,14 +62,12 @@ WormsDemo =
, textitems = accGSt WormsTextItems , textitems = accGSt WormsTextItems
} }
/* if the quit function returns true, the game engine quit the level */ /* if the quit function returns true, the game engine quit the level */
WormsQuitFunction :: GameState -> (Bool, GameState) WormsQuitFunction :: GameState -> (Bool, GameState)
WormsQuitFunction gst WormsQuitFunction gst
= (gst.quit, gst) = (gst.quit, gst)
/* function that returns the next level to run, 0 = end game */ /* function that returns the next level to run, 0 = end game */
WormsNextLevelFunction :: GameState -> (Int, GameState) WormsNextLevelFunction :: GameState -> (Int, GameState)
...@@ -106,94 +106,30 @@ H :== 24 ...@@ -106,94 +106,30 @@ H :== 24
DEFAULT_SIZE :== {w = W, h = H} DEFAULT_SIZE :== {w = W, h = H}
/* object codes (corresponds with level map) */ /* ---------- levels ---------- */
OBJ_START :== 0x10
OBJ_WORMHEAD :== 0x10
OBJ_WORMSEGMENT :== 0x11
OBJ_FOOD :== 0x12
OBJ_WALL :== 0x80
/* user events */
EV_STOP :== 0
EV_DIE :== 1
EV_GAMEOVER :== 2
EV_END_LEVEL :== 3
/* ---------- level 1 ---------- */
GameLevel1 GameLevel1
= { boundmap = { map = Level1Bounds = { DefaultLevel
, blocksize = DEFAULT_SIZE & boundmap = Level1Map1BoundMap
, objstart = OBJ_START , layers = [Level1Map1Layer]
, startobjx = 0 , music = Just BackgroundMusic
, startobjy = 0
}
, initpos = {x = W - 8, y = 0}
, layers = [Level1Layer]
, objects = ObjectList
, music = Just BackGroundMusic
, soundsamples = SoundSampleList
, leveloptions = { fillbackground = Nothing
, escquit = False
, debugscroll = False
, fadein = False
, fadeout = False
}
} }
Level1Layer =
{ bmp = Level1Bitmap
, layermap = Level1Map
, sequences = []
, movement = defaultMovement
}
/* ---------- level 2 ---------- */
GameLevel2 GameLevel2
= { boundmap = { map = Level2Bounds = { DefaultLevel
, blocksize = DEFAULT_SIZE & boundmap = Level2Map1BoundMap
, objstart = OBJ_START , layers = [Level2Map1Layer]
, startobjx = 0
, startobjy = 0
}
, initpos = {x = W - 8, y = 0}
, layers = [Level2Layer]
, objects = ObjectList
, music = Nothing
, soundsamples = SoundSampleList
, leveloptions = { fillbackground = Nothing
, escquit = False
, debugscroll = False
, fadein = False
, fadeout = False
}
}
Level2Layer =
{ bmp = Level2Bitmap
, layermap = Level2Map
, sequences = []
, movement = defaultMovement
} }
/* ---------- level 3 ---------- */
GameLevel3 GameLevel3
= { boundmap = { map = Level3Bounds = { DefaultLevel
, blocksize = DEFAULT_SIZE & boundmap = Level3Map1BoundMap
, objstart = OBJ_START , layers = [Level3Map1Layer]
, startobjx = 0 }
, startobjy = 0
} DefaultLevel
, initpos = {x = W - 8, y = 0} = { blankScreen
, layers = [Level3Layer] & initpos = {x = W - 8, y = 0}
, objects = ObjectList , objects = ObjectList
, music = Nothing , music = Nothing
, soundsamples = SoundSampleList , soundsamples = SoundSampleList
...@@ -205,14 +141,21 @@ GameLevel3 ...@@ -205,14 +141,21 @@ GameLevel3
} }
} }
Level3Layer = /* ---------- objects ---------- */
{ bmp = Level3Bitmap
, layermap = Level3Map
, sequences = []
, movement = defaultMovement
}
/* object codes (corresponds with level map) */
OBJ_WORMHEAD :== 0x10
OBJ_WORMSEGMENT :== 0x11
OBJ_FOOD :== 0x12
OBJ_WALL :== 0x80
/* user events */
EV_STOP :== 0
EV_DIE :== 1
EV_GAMEOVER :== 2
EV_END_LEVEL :== 3
/* ---------- worm object ---------- */ /* ---------- worm object ---------- */
...@@ -230,11 +173,6 @@ BND_WORMSEGMENT :== 0x0002 ...@@ -230,11 +173,6 @@ BND_WORMSEGMENT :== 0x0002
BND_FOOD :== 0x0004 BND_FOOD :== 0x0004
BND_WALL :== 0x0008 BND_WALL :== 0x0008
/*
the wormstate contains the next x/y direction to move, the position where
new segments can be added, and the sprites for all directions
*/
:: WormState :: WormState
= { xv :: !Real /* next x-speed */ = { xv :: !Real /* next x-speed */
, yv :: !Real /* next y-speed */ , yv :: !Real /* next y-speed */
...@@ -245,7 +183,6 @@ BND_WALL :== 0x0008 ...@@ -245,7 +183,6 @@ BND_WALL :== 0x0008
, next :: !Int /* next sprite */ , next :: !Int /* next sprite */
} }
/* layer height, to display some objects in front of others */ /* layer height, to display some objects in front of others */
NormalLayer = 1 NormalLayer = 1
TopLayer = 2 TopLayer = 2
...@@ -253,7 +190,11 @@ TopLayer = 2 ...@@ -253,7 +190,11 @@ TopLayer = 2
WormHead WormHead
# obj = defaultGameObject OBJ_WORMHEAD sz wormstate # obj = defaultGameObject OBJ_WORMHEAD sz wormstate
# obj = { obj # obj = { obj
& sprites = WormHeadSpriteList & sprites = [ WormHeadSprite1
, WormHeadSprite2
, WormHeadSprite3
, WormHeadSprite4
]
, init = (newInit sz wormstate) , init = (newInit sz wormstate)
, keydown = newKeyDown , keydown = newKeyDown
, move = newMove , move = newMove
...@@ -386,11 +327,10 @@ where ...@@ -386,11 +327,10 @@ where
= quitlevel {st=st, or=or, gs=gs} = quitlevel {st=st, or=or, gs=gs}
= {st=st, or=or, gs=gs} = {st=st, or=or, gs=gs}
WormSegment WormSegment
# obj = defaultGameObject OBJ_WORMSEGMENT sz Void # obj = defaultGameObject OBJ_WORMSEGMENT sz Void
# obj = { obj # obj = { obj
& sprites = [WormSegmentSprite] & sprites = [WormSegmentSprite1]
, init = (newInit sz Void) , init = (newInit sz Void)
, move = newMove , move = newMove
, userevent = newUserEvent , userevent = newUserEvent
...@@ -404,7 +344,7 @@ where ...@@ -404,7 +344,7 @@ where
# objrec = { objrec # objrec = { objrec
& ownbounds = if (subtype > 1) BND_WORMSEGMENT 0 & ownbounds = if (subtype > 1) BND_WORMSEGMENT 0
, collidebounds = 0 , collidebounds = 0
, skipmove = 0 // toInt (2.0 / V) -1 , skipmove = 0 // toInt (2.0 / V) -1
, layer = AtLayer NormalLayer , layer = AtLayer NormalLayer
} }
= {st=state, or=objrec, gs=gs} = {st=state, or=objrec, gs=gs}
...@@ -433,7 +373,6 @@ where ...@@ -433,7 +373,6 @@ where
/* ---------- wall object ---------- */ /* ---------- wall object ---------- */
Wall Wall
# obj = defaultGameObject OBJ_WALL sz Void # obj = defaultGameObject OBJ_WALL sz Void
# obj = {obj & init = (newInit sz Void)} # obj = {obj & init = (newInit sz Void)}
...@@ -446,7 +385,6 @@ where ...@@ -446,7 +385,6 @@ where
= {st=state, or=objrec, gs=gs} = {st=state, or=objrec, gs=gs}
/* ---------- food object ---------- */ /* ---------- food object ---------- */
SPR_INVISIBLE = 0 SPR_INVISIBLE = 0
...@@ -455,7 +393,7 @@ SPR_VISIBLE = 1 ...@@ -455,7 +393,7 @@ SPR_VISIBLE = 1
Food Food
# obj = defaultGameObject OBJ_FOOD sz Void # obj = defaultGameObject OBJ_FOOD sz Void
# obj = { obj # obj = { obj
& sprites = [WormFoodSprite] & sprites = [FoodSprite1]
, init = (newInit sz Void) , init = (newInit sz Void)
, move = newMove , move = newMove
, touchbound = newTouchBound , touchbound = newTouchBound
...@@ -518,6 +456,7 @@ where ...@@ -518,6 +456,7 @@ where
= {st=st, or=or, gs=gs} = {st=st, or=or, gs=gs}
= {st=st, or=or, gs=gs} = {st=st, or=or, gs=gs}
/* ---------- useful functions for objects ---------- */ /* ---------- useful functions for objects ---------- */
/* quit the level */ /* quit the level */
...@@ -548,37 +487,16 @@ getgstgameover :: GameState -> (Bool, GameState) ...@@ -548,37 +487,16 @@ getgstgameover :: GameState -> (Bool, GameState)
getgstgameover gst = (gst.gameover, gst) getgstgameover gst = (gst.gameover, gst)
/* ---------- music ---------- */ /* ---------- music ---------- */
BackGroundMusic BackgroundMusic
= { musicfile = "Worms.mid" = { musicfile = "music\\Worms.mid"
, restart = True , restart = True
, continue = True , continue = True
} }
/* ---------- bitmaps and sprites ---------- */ /* ---------- text items ---------- */
WormHeadSpriteList = [ws SPR_WH_UP, ws SPR_WH_LEFT, ws SPR_WH_DOWN, ws SPR_WH_RIGHT]
where
ws :: Int -> Sprite
ws n = { bitmap = HeadBitmap, sequence = [(n, 100)], loop = True }
WormSegmentSprite =
{ bitmap = WormBitmap
, sequence = [(3,100)]
, loop = True
}
WormFoodSprite =
{ bitmap = WormBitmap
, sequence = [(1,35),(2,35)]
, loop = True
}
/* ---------- statistics ---------- */
BigStyle = BigStyle =
{ fontname = "Arial" { fontname = "Arial"
...@@ -642,13 +560,13 @@ gsrand gs=:{randseed} ...@@ -642,13 +560,13 @@ gsrand gs=:{randseed}
# (x, newseed) = random randseed # (x, newseed) = random randseed
= (x, {gs & randseed = newseed}) = (x, {gs & randseed = newseed})
/* ---------- sound samples ---------- */
SND_FOOD :== 1 SND_FOOD :== 1
SND_HIT :== 2 SND_HIT :== 2
SoundSampleList = SoundSampleList =
[ { soundid = SND_FOOD, soundfile = "FOOD.WAV", soundbuffers = 3 } [ { soundid = SND_FOOD, soundfile = "sounds\\FOOD.WAV", soundbuffers = 3 }
, { soundid = SND_HIT, soundfile = "HIT.WAV", soundbuffers = 5 } , { soundid = SND_HIT, soundfile = "sounds\\HIT.WAV", soundbuffers = 5 }
] ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment