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
/*
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)
Note: To play Worms with background music, copy your favourite MIDI file
to Worms.mid in the music\ subdirectory.
*/
import StdEnv, StdIO
import StdGameDef, StdGame, StdGSt, GameFunctions
import L1, L2, L3, WORM, HEAD
import Random, notes
import StdEnv, StdIO, StdGameDef, StdGame, StdGSt, GameFunctions, Random, notes
import WormsGfx /* generated by Tile Studio */
:: GameState
= { curlevel :: !Int
......@@ -32,6 +34,7 @@ initialGameState = { curlevel = 0
}
/* move with speed V */
V = 3.0 /* 24 rem V must be 0 */
/* ---------- main program: load game definition and start the game! ---------- */
......@@ -42,7 +45,6 @@ Start world
= startGame WormsDemo {initialGameState & randseed = seed}
[ScreenSize {w = 640, h = 480}, ColorDepth 16] world
/* ---------- the complete game definition ---------- */
WormsDemo :: (Game GameState)
......@@ -60,14 +62,12 @@ WormsDemo =
, textitems = accGSt WormsTextItems
}
/* if the quit function returns true, the game engine quit the level */
WormsQuitFunction :: GameState -> (Bool, GameState)
WormsQuitFunction gst
= (gst.quit, gst)
/* function that returns the next level to run, 0 = end game */
WormsNextLevelFunction :: GameState -> (Int, GameState)
......@@ -106,94 +106,30 @@ H :== 24
DEFAULT_SIZE :== {w = W, h = H}
/* object codes (corresponds with level map) */
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 ---------- */
/* ---------- levels ---------- */
GameLevel1
= { boundmap = { map = Level1Bounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, startobjx = 0
, 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
}
= { DefaultLevel
& boundmap = Level1Map1BoundMap
, layers = [Level1Map1Layer]
, music = Just BackgroundMusic
}
Level1Layer =
{ bmp = Level1Bitmap
, layermap = Level1Map
, sequences = []
, movement = defaultMovement
}
/* ---------- level 2 ---------- */
GameLevel2
= { boundmap = { map = Level2Bounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, 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
= { DefaultLevel
& boundmap = Level2Map1BoundMap
, layers = [Level2Map1Layer]
}
/* ---------- level 3 ---------- */
GameLevel3
= { boundmap = { map = Level3Bounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, startobjx = 0
, startobjy = 0
= { DefaultLevel
& boundmap = Level3Map1BoundMap
, layers = [Level3Map1Layer]
}
, initpos = {x = W - 8, y = 0}
, layers = [Level3Layer]
DefaultLevel
= { blankScreen
& initpos = {x = W - 8, y = 0}
, objects = ObjectList
, music = Nothing
, soundsamples = SoundSampleList
......@@ -205,14 +141,21 @@ GameLevel3
}
}
Level3Layer =
{ bmp = Level3Bitmap
, layermap = Level3Map
, sequences = []
, movement = defaultMovement
}
/* ---------- objects ---------- */
/* 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 ---------- */
......@@ -230,11 +173,6 @@ BND_WORMSEGMENT :== 0x0002
BND_FOOD :== 0x0004
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
= { xv :: !Real /* next x-speed */
, yv :: !Real /* next y-speed */
......@@ -245,7 +183,6 @@ BND_WALL :== 0x0008
, next :: !Int /* next sprite */
}
/* layer height, to display some objects in front of others */
NormalLayer = 1
TopLayer = 2
......@@ -253,7 +190,11 @@ TopLayer = 2
WormHead
# obj = defaultGameObject OBJ_WORMHEAD sz wormstate
# obj = { obj
& sprites = WormHeadSpriteList
& sprites = [ WormHeadSprite1
, WormHeadSprite2
, WormHeadSprite3
, WormHeadSprite4
]
, init = (newInit sz wormstate)
, keydown = newKeyDown
, move = newMove
......@@ -386,11 +327,10 @@ where
= quitlevel {st=st, or=or, gs=gs}
= {st=st, or=or, gs=gs}
WormSegment
# obj = defaultGameObject OBJ_WORMSEGMENT sz Void
# obj = { obj
& sprites = [WormSegmentSprite]
& sprites = [WormSegmentSprite1]
, init = (newInit sz Void)
, move = newMove
, userevent = newUserEvent
......@@ -433,7 +373,6 @@ where
/* ---------- wall object ---------- */
Wall
# obj = defaultGameObject OBJ_WALL sz Void
# obj = {obj & init = (newInit sz Void)}
......@@ -446,7 +385,6 @@ where
= {st=state, or=objrec, gs=gs}
/* ---------- food object ---------- */
SPR_INVISIBLE = 0
......@@ -455,7 +393,7 @@ SPR_VISIBLE = 1
Food
# obj = defaultGameObject OBJ_FOOD sz Void
# obj = { obj
& sprites = [WormFoodSprite]
& sprites = [FoodSprite1]
, init = (newInit sz Void)
, move = newMove
, touchbound = newTouchBound
......@@ -518,6 +456,7 @@ where
= {st=st, or=or, gs=gs}
= {st=st, or=or, gs=gs}
/* ---------- useful functions for objects ---------- */
/* quit the level */
......@@ -548,37 +487,16 @@ getgstgameover :: GameState -> (Bool, GameState)
getgstgameover gst = (gst.gameover, gst)
/* ---------- music ---------- */
BackGroundMusic
= { musicfile = "Worms.mid"
BackgroundMusic
= { musicfile = "music\\Worms.mid"
, restart = True
, continue = True
}
/* ---------- bitmaps and sprites ---------- */
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 ---------- */
/* ---------- text items ---------- */
BigStyle =
{ fontname = "Arial"
......@@ -642,13 +560,13 @@ gsrand gs=:{randseed}
# (x, newseed) = random randseed
= (x, {gs & randseed = newseed})
/* ---------- sound samples ---------- */
SND_FOOD :== 1
SND_HIT :== 2
SoundSampleList =
[ { soundid = SND_FOOD, soundfile = "FOOD.WAV", soundbuffers = 3 }
, { soundid = SND_HIT, soundfile = "HIT.WAV", soundbuffers = 5 }
[ { soundid = SND_FOOD, soundfile = "sounds\\FOOD.WAV", soundbuffers = 3 }
, { 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