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

Game Examples now use Tile Studio instead of GRED/EDLEV

parent b59a0b2c
......@@ -7,52 +7,10 @@ module Charlie
Mike Wiering (mike.wiering@cs.kun.nl)
*/
/*
To edit the the first level (in DOS):
cd levels
edlev L1
conv L1 Level1
To edit the main character:
cd objects
edlev CH
conv CH MainChar
Use make.bat to convert all graphics.
*/
import StdGameDef, StdGame, StdGSt, GameFunctions, StdProcess, Random, notes
import StdGameDef
import StdGame
import StdGSt
import GameFunctions
import StdProcess
import Random
/* music notes */
import notes
/* levels */
import TITLE
import L1
import L2
/* sprites */
import OBJ
import CLOUDS
import ENEMY
import BEES
import FROGS
import CH
import PART
import PALM
import WATER
import ENDING
import STATUS
import INFRONT
import CharlieGfx /* generated by Tile Studio */
DEFAULT_LIVES :== 3
:: GameState
= { curlevel :: !Int
......@@ -69,6 +27,8 @@ DEFAULT_LIVES :== 3
, randseed :: !RandomSeed
}
DEFAULT_LIVES :== 3
initialGameState = { curlevel = 0
, maxlevel = 3
, titlescreen = False
......@@ -108,7 +68,7 @@ DuckGame =
]
, quitlevel = accGSt QuitFunction
, nextlevel = accGSt NextLevelFunction
, textitems = accGSt Statistics
, textitems = accGSt TextItems
}
/* if the quit function returns true, the game engine quit the level */
......@@ -154,8 +114,8 @@ where
/* function that returns text to be displayed */
Statistics :: GameState -> ([GameText], GameState)
Statistics gst
TextItems :: GameState -> ([GameText], GameState)
TextItems gst
| gst.titlescreen
= ([ TitleTextShadow, TitleText
, DemoText
......@@ -220,8 +180,9 @@ BND_STATIC_BOUNDS :== (1 << 31)
OBJ_AUTOINIT :== 0
OBJ_START :== 0x10 /* lower map values are subtypes */
/*
OBJ_START :== 0x10 // lower map values are subtypes
*/
OBJ_STATIC_COIN :== 0x10
OBJ_FALLING_COIN :== 0x11
OBJ_STATIC_DIAMOND :== 0x12
......@@ -282,24 +243,22 @@ GameObjectList = [ AutoInitObject
, FlashObject
, EndingObject
, StatHeartObject
, BlockInFrontObject OBJ_GROUND1 (InFrontSprite 1)
, BlockInFrontObject OBJ_GROUND2 (InFrontSprite 2)
, BlockInFrontObject OBJ_GROUND3 (InFrontSprite 3)
, BlockInFrontObject OBJ_GROUND1 (InFrontSprite1)
, BlockInFrontObject OBJ_GROUND2 (InFrontSprite2)
, BlockInFrontObject OBJ_GROUND3 (InFrontSprite3)
, PinObject
]
/* ---------- background cloud ---------- */
/*
Because we only have a few little clouds, we will use
objects instead of a complete layer here.
*/
/* Because we only have a few little clouds, we will use
objects instead of a complete layer here. */
CloudObject
# obj = defaultGameObject OBJ_CLOUD size Void
# obj = { obj
& sprites = [CloudSprite]
& sprites = [CloudSprite2]
, init = newinit size Void
}
= obj
......@@ -322,16 +281,14 @@ where
/* ---------- palm front object ---------- */
/*
This object is the part of a palm tree that is shown in front
/* This object is the part of a palm tree that is shown in front
of Charlie. This could also be done with a complete layer, but
again for speed we will use objects.
*/
again for speed we will use objects. */
PalmFrontObject
# obj = defaultGameObject OBJ_PALM size Void
# obj = { obj
& sprites = [PalmSprite 2, PalmSprite 1, PalmSprite 3]
& sprites = [PalmSprite2, PalmSprite1, PalmSprite3]
, init = newinit size Void
}
= obj
......@@ -371,12 +328,12 @@ where
SPR_ITEM :== 1
SPR_GLITTER :== 2
StaticCoinObject = StaticGameItem OBJ_STATIC_COIN (CoinSprite 8)
FallingCoinObject = FallingGameItem OBJ_FALLING_COIN (CoinSprite 8)
StaticDiamondObject = StaticGameItem OBJ_STATIC_DIAMOND DiamondSprite
FallingDiamondObject = FallingGameItem OBJ_FALLING_DIAMOND DiamondSprite
HeartObject = FallingGameItem OBJ_HEART HeartSprite
LifeObject = FallingGameItem OBJ_LIFE LifeSprite
StaticCoinObject = StaticGameItem OBJ_STATIC_COIN ItemSprite3
FallingCoinObject = FallingGameItem OBJ_FALLING_COIN ItemSprite3
StaticDiamondObject = StaticGameItem OBJ_STATIC_DIAMOND ItemSprite2
FallingDiamondObject = FallingGameItem OBJ_FALLING_DIAMOND ItemSprite2
HeartObject = FallingGameItem OBJ_HEART ItemSprite6
LifeObject = FallingGameItem OBJ_LIFE ItemSprite5
FallingGameItem objectcode sprite
# obj = StaticGameItem objectcode sprite
......@@ -412,7 +369,7 @@ where
StaticGameItem objectcode sprite
# obj = defaultGameObject objectcode size Void
# obj = { obj
& sprites = [sprite, GlitterSprite 25]
& sprites = [sprite, ItemAnimation4]
, init = newinit size Void
, collide = newcollide
, animation = killobject
......@@ -470,25 +427,14 @@ ItemScoreAndSound ot gs
= if (ot == OBJ_LIFE) (500, inclives gs) (100, gs)
= (100, gs)
/*
OBJ_STATIC_COIN :== 0x10
OBJ_FALLING_COIN :== 0x11
OBJ_STATIC_DIAMOND :== 0x12
OBJ_FALLING_DIAMOND :== 0x13
OBJ_HEART :== 0x14
OBJ_LIFE :== 0x15
*/
killobject objst=:{or=or}
= {objst & or={or & active = False}}
/* ---------- crates ---------- */
/*
Crates contain items which appear when Charlie opens these
crates by jumping on top of them.
*/
/* crates contain items which appear when Charlie opens these crates by
jumping on top of them */
CrateObject = Crate True
InvisibleCrateObject = Crate False
......@@ -496,7 +442,7 @@ InvisibleCrateObject = Crate False
Crate visible
# obj = defaultGameObject (if visible OBJ_CRATE OBJ_INVISIBLE_CRATE) size Void
# obj = { obj
& sprites = [CrateSprite]
& sprites = [ItemSprite1]
, init = newinit size Void
, collide = newcollide
}
......@@ -551,7 +497,7 @@ where
CratePartObject
# obj = defaultGameObject OBJ_CRATE_PART size Void
# obj = { obj
& sprites = [CratePartSprite]
& sprites = [PartSprite1]
, init = newinit size Void
}
= obj
......@@ -584,7 +530,7 @@ where
FlashObject
# obj = defaultGameObject OBJ_FLASH size Void
# obj = { obj
& sprites = [FlashSprite]
& sprites = [FlashAnimation1]
, init = newinit size Void
, animation = killobject
}
......@@ -605,7 +551,7 @@ where
BounceBlockObject
# obj = defaultGameObject OBJ_BOUNCEBLOCK size Void
# obj = { obj
& sprites = [BounceBlockSprite, BounceBlockShortSprite]
& sprites = [ItemSprite7, ItemAnimation7]
, init = newinit size Void
, collide = newcollide
, animation = newanimation
......@@ -652,7 +598,7 @@ where
WaterObject
# obj = defaultGameObject OBJ_WATER size Void
# obj = { obj
& sprites = [WaterSprite]
& sprites = [WaterSprite1]
, init = newinit size Void
}
= obj
......@@ -686,7 +632,7 @@ Splash pos gs
SplashObject
# obj = defaultGameObject OBJ_SPLASH size Void
# obj = { obj
& sprites = [WaveSprite, WaveSprite, SplashSprite]
& sprites = [WaterAnimation2, WaterAnimation2, WaterAnimation3]
, init = newinit size Void
, animation = killobject
}
......@@ -779,7 +725,7 @@ where
/* ---------- flying enemies ---------- */
BeeObject = FlyingObject OBJ_BEE [BeeSprite]
BeeObject = FlyingObject OBJ_BEE [BeeSprite1]
FlyingObject objtype sprlist
# obj = defaultGameObject objtype size Void
......@@ -834,7 +780,7 @@ where
FrogObject
# obj = defaultGameObject OBJ_FROG size Void
# obj = { obj
& sprites = [FrogSprite, FrogJumpSprite]
& sprites = [FrogAnimation1, FrogAnimation2]
, init = newinit size Void
, collide = newcollide
, animation = newanimation
......@@ -879,9 +825,9 @@ where
EndingObject
# obj = defaultGameObject OBJ_ENDING size Void
# obj = { obj
& sprites = [ EndingSprite 1, EndingSprite 2, EndingSprite 3
, EndingSprite 4, EndingSprite 5, EndingSprite 6
, EndingSprite 7, EndingSprite 8]
& sprites = [ EndingSprite1, EndingSprite2, EndingSprite3
, EndingSprite4, EndingSprite5, EndingSprite6
, EndingSprite7, EndingSprite8]
, init = newinit size Void
, collide = newcollide
, move = newmove
......@@ -930,7 +876,7 @@ where
| otherwise = 0
/* ---------- statistics objects ---------- */
/* ---------- text items ---------- */
ST_X :== 10
ST_COLON :== 11
......@@ -940,8 +886,8 @@ ST_COIN :== 13
StatHeartObject
# obj = defaultGameObject OBJ_STAT size Void
# obj = { obj
& sprites = [StatusSprite 1, StatusSprite 2, StatusSprite 3,
StatusSprite 4, StatusSprite 5, StatusSprite 6]
& sprites = [StatusSprite1, StatusSprite2, StatusSprite3,
StatusSprite4, StatusSprite5, StatusSprite6]
, init = newinit size Void
, userevent = newuserevent
}
......@@ -968,9 +914,7 @@ where
/* ---------- autoinit object ---------- */
/*
this object is automatically initialized when the level starts
*/
/* this object is automatically initialized when the level starts */
AutoInitObject
# obj = defaultGameObject OBJ_AUTOINIT size Void
......@@ -1021,12 +965,8 @@ MC_DEAD :== 6
MainCharObject
# obj = defaultGameObject OBJ_MAIN_CHAR size newstate
# obj = { obj
& sprites = [ CharlieIdleSprite
, CharlieWalkSprite
, CharlieJumpSprite
, CharlieFallSprite
, CharlieSwimSprite
, CharlieDeadSprite
& sprites = [ CharlieAnimation1, CharlieAnimation2, CharlieAnimation3
, CharlieAnimation4, CharlieAnimation5, CharlieSprite6
]
, init = newinit size newstate
, keydown = newkeydown
......@@ -1145,11 +1085,13 @@ where
where
jumpspeed :: !RealXY -> RealXY
jumpspeed sp=:{rx, ry} = {rx = rx, ry = ry - 4.35 - abs (rx) / 3.0}
/*
setaction :: !Int Int -> Int
setaction cur new = if ((cur == MC_WALK) ||
(cur == MC_IDLE))
new
cur
*/
newkeyup key objst=:{st=st, or=or, gs=gs}
| key == GK_LEFT = {objst & or={or & acceleration.rx = or.acceleration.rx + ac}}
......@@ -1284,7 +1226,7 @@ where
AutoMenuObject
# obj = defaultGameObject OBJ_AUTOINIT size newstate
# obj = { obj
& sprites = [PointerSprite]
& sprites = [ItemSprite8]
, init = newinit size newstate
, keydown = newkeydown
}
......@@ -1323,14 +1265,9 @@ where
/* ---------- Title screen ---------- */
TitleScreen
= { boundmap = { map = TitleBounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, startobjx = 4
, startobjy = 4
}
= { boundmap = ChTitleBoundMap
, initpos = {x = 0, y = 13 * H + H / 2}
, layers = [TitleBackground, TitleLayer]
, layers = [BackGr3Map1Layer, ChTitleLayer]
, objects = [{MainCharObject & keydown = nop, keyup = nop}, AutoMenuObject]
, music = Just BackgroundMusic
, soundsamples = []
......@@ -1344,32 +1281,12 @@ TitleScreen
where
nop = \k st -> st
TitleLayer =
{ bmp = TitleBitmap
, layermap = TitleMap
, sequences = []
, movement = defaultMovement
}
TitleBackground =
{ bmp = TitleBackgrBitmap
, layermap = [{1}]
, sequences = []
, movement = defaultScrollMovement 3
}
/* ---------- level 1 ---------- */
GameLevel1
= { boundmap = { map = Level1Bounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, startobjx = 4
, startobjy = 4
}
= { boundmap = { ChLevel1BoundMap & startobjx = 4, startobjy = 4 }
, initpos = {x = 0, y = 13 * H + H / 2}
, layers = [Level1Background, Level1Layer]
, layers = [BackGr1Map1Layer, ChLevel1Layer]
, objects = GameObjectList
, music = Nothing // Just BackgroundMusic
, soundsamples = GameSoundSampleList
......@@ -1381,31 +1298,12 @@ GameLevel1
}
}
Level1Layer =
{ bmp = Level1Bitmap
, layermap = Level1Map
, sequences = []
, movement = defaultMovement
}
Level1Background =
{ bmp = ForestBackground
, layermap = [{1}]
, sequences = []
, movement = defaultScrollMovement 3
}
/* ---------- level 2 ---------- */
GameLevel2
= { boundmap = { map = Level2Bounds
, blocksize = DEFAULT_SIZE
, objstart = OBJ_START
, startobjx = 4
, startobjy = 4
}
= { boundmap = { ChLevel2BoundMap & startobjx = 4, startobjy = 4 }
, initpos = {x = 0, y = 13 * H + H / 2}
, layers = [Level2Background, Level2Layer]
, layers = [BackGr2Map1Layer, ChLevel2Layer]
, objects = GameObjectList
, music = Nothing // Just BackgroundMusic
, soundsamples = GameSoundSampleList
......@@ -1417,22 +1315,6 @@ GameLevel2
}
}
Level2Layer =
{ bmp = Level2Bitmap
, layermap = Level2Map
, sequences = []
, movement = defaultMovement
}
Level2Background =
{ bmp = NightBackground
, layermap = [{1}]
, sequences = []
, movement = defaultScrollMovement 3
}
/* ---------- useful functions for objects ---------- */
/* quit the level */
......@@ -1480,7 +1362,6 @@ where
addgstscore :: Int GameState -> GameState
addgstscore points gst = {gst & score = gst.score + points}
/* gameover functions */
setgameover gs = appGSt setgstgameover gs
setgstgameover :: GameState -> GameState
......@@ -1520,7 +1401,7 @@ MAX_RAND = 65535
/* ---------- music and sounds ---------- */
BackgroundMusic
= { musicfile = "Charlie.mid"
= { musicfile = "music\\Charlie.mid"
, restart = True
, continue = False
}
......@@ -1549,267 +1430,24 @@ SND_CLARINET :== 13
SND_AU :== 14
GameSoundSampleList =
[ { soundid = SND_JUMP , soundfile = "JUMP.WAV" , soundbuffers = 1 }
, { soundid = SND_SPLASH , soundfile = "WATER.WAV" , soundbuffers = 3 }
, { soundid = SND_WATER_JUMP , soundfile = "WATERJMP.WAV" , soundbuffers = 8 }
, { soundid = SND_COIN , soundfile = "COIN.WAV" , soundbuffers = 20 }
, { soundid = SND_CRATE , soundfile = "CRATE.WAV" , soundbuffers = 2 }
, { soundid = SND_ENEMY , soundfile = "ENEMY.WAV" , soundbuffers = 3 }
, { soundid = SND_PLOF , soundfile = "PLOF.WAV" , soundbuffers = 1 }
, { soundid = SND_HIT , soundfile = "HIT.WAV" , soundbuffers = 3 }
, { soundid = SND_FROG , soundfile = "FROG.WAV" , soundbuffers = 2 }
, { soundid = SND_BEE , soundfile = "BEE.WAV" , soundbuffers = 2 }
, { soundid = SND_XYLOFOON , soundfile = "XYLOFOON.WAV" , soundbuffers = 8 }
, { soundid = SND_FLUTE , soundfile = "FLUTE.WAV" , soundbuffers = 8 }
, { soundid = SND_CLARINET , soundfile = "CLARINET.WAV" , soundbuffers = 8 }
, { soundid = SND_AU , soundfile = "AU.WAV" , soundbuffers = 5 }
[ { soundid = SND_JUMP , soundfile = "sounds\\JUMP.WAV" , soundbuffers = 1 }
, { soundid = SND_SPLASH , soundfile = "sounds\\WATER.WAV" , soundbuffers = 3 }
, { soundid = SND_WATER_JUMP , soundfile = "sounds\\WATERJMP.WAV" , soundbuffers = 8 }
, { soundid = SND_COIN , soundfile = "sounds\\COIN.WAV" , soundbuffers = 20 }
, { soundid = SND_CRATE , soundfile = "sounds\\CRATE.WAV" , soundbuffers = 2 }
, { soundid = SND_ENEMY , soundfile = "sounds\\ENEMY.WAV" , soundbuffers = 3 }
, { soundid = SND_PLOF , soundfile = "sounds\\PLOF.WAV" , soundbuffers = 1 }
, { soundid = SND_HIT , soundfile = "sounds\\HIT.WAV" , soundbuffers = 3 }
, { soundid = SND_FROG , soundfile = "sounds\\FROG.WAV" , soundbuffers = 2 }
, { soundid = SND_BEE , soundfile = "sounds\\BEE.WAV" , soundbuffers = 2 }
, { soundid = SND_XYLOFOON , soundfile = "sounds\\XYLOFOON.WAV" , soundbuffers = 8 }
, { soundid = SND_FLUTE , soundfile = "sounds\\FLUTE.WAV" , soundbuffers = 8 }
, { soundid = SND_CLARINET , soundfile = "sounds\\CLARINET.WAV" , soundbuffers = 8 }
, { soundid = SND_AU , soundfile = "sounds\\AU.WAV" , soundbuffers = 5 }
]
/* ---------- bitmaps and sprites ---------- */
TitleBackgrBitmap :: GameBitmap
TitleBackgrBitmap
= { bitmapname = "TitleBackground.BMP"
, unitsize = {w = 320, h = 320}
, dimensions = (1, 1)
, transparent = Nothing
}
ForestBackground :: GameBitmap
ForestBackground
= { bitmapname = "ForestBackground.BMP"
, unitsize = {w = 320, h = 320}
, dimensions = (1, 1)
, transparent = Nothing
}
NightBackground :: GameBitmap
NightBackground
= { bitmapname = "NightBackground.BMP"
, unitsize = {w = 320, h = 320}
, dimensions = (1, 1)
, transparent = Nothing
}
CloudSprite :: Sprite
CloudSprite
= { bitmap = CloudsBitmap
, sequence = BitmapSequence 3 2 50
, loop = True
}
CrateSprite :: Sprite
CrateSprite
= { bitmap = ObjectsBitmap
, sequence = BitmapSequence 1 2 60
, loop = True
}
CratePartSprite :: Sprite
CratePartSprite
= { bitmap = PartBitmap
, sequence = [(1, 100)]
, loop = True
}
DiamondSprite :: Sprite
DiamondSprite
= { bitmap = ObjectsBitmap
, sequence = BitmapSequence 3 2 55
, loop = True
}
CoinSprite :: Int -> Sprite
CoinSprite speed
= { bitmap = ObjectsBitmap
, sequence = BitmapSequence 5 8 speed
, loop = True
}
GlitterSprite :: Int -> Sprite
GlitterSprite speed
= { bitmap = ObjectsBitmap
, sequence = BitmapSequence 13 4 speed
, loop = False
}
LifeSprite :: Sprite
LifeSprite
= { bitmap = ObjectsBitmap
, sequence = BitmapSequence 17 2 50
, loop = True