Commit 8fb27ad6 authored by Peter Achten's avatar Peter Achten
Browse files

no message

parent 3cb3e377
definition module BEES
import StdEnv, StdGameDef
BeesBitmap :: GameBitmap
BeesMap :: [{#Int}]
BeesSeq001 :: (Int, [(Int, Int)])
BeesSequences :: [(Int, [(Int, Int)])]
implementation module BEES
import StdEnv, StdGameDef
BeesBitmap :: GameBitmap
BeesBitmap
= { bitmapname = "BEES.BMP"
, unitsize = { w = 20, h = 20 }
, dimensions = (16, 1)
, transparent = Just { x = 59, y = 19 }
}
BeesMap :: [{#Int}]
BeesMap = [{1,2,3,2,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1}]
BeesSeq001 :: (Int, [(Int, Int)])
BeesSeq001 = (-1,[])
BeesSequences :: [(Int, [(Int, Int)])]
BeesSequences = [BeesSeq001]
\ No newline at end of file
definition module CH
import StdEnv, StdGameDef
MainCharBitmap :: GameBitmap
MainCharMap :: [{#Int}]
MainCharSeq001 :: (Int, [(Int, Int)])
MainCharSequences :: [(Int, [(Int, Int)])]
implementation module CH
import StdEnv, StdGameDef
MainCharBitmap :: GameBitmap
MainCharBitmap
= { bitmapname = "CH.BMP"
, unitsize = { w = 24, h = 34 }
, dimensions = (13, 1)
, transparent = Just { x = 191, y = 33 }
}
MainCharMap :: [{#Int}]
MainCharMap = [{1,2,3,4,5,6,7,8,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}]
MainCharSeq001 :: (Int, [(Int, Int)])
MainCharSeq001 = (-1,[])
MainCharSequences :: [(Int, [(Int, Int)])]
MainCharSequences = [MainCharSeq001]
\ No newline at end of file
definition module CLOUDS
import StdEnv, StdGameDef
CloudsBitmap :: GameBitmap
CloudsMap :: [{#Int}]
CloudsSeq001 :: (Int, [(Int, Int)])
CloudsSeq002 :: (Int, [(Int, Int)])
CloudsSequences :: [(Int, [(Int, Int)])]
implementation module CLOUDS
import StdEnv, StdGameDef
CloudsBitmap :: GameBitmap
CloudsBitmap
= { bitmapname = "CLOUDS.BMP"
, unitsize = { w = 40, h = 24 }
, dimensions = (8, 1)
, transparent = Just { x = 159, y = 23 }
}
CloudsMap :: [{#Int}]
CloudsMap = [{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}]
CloudsSeq001 :: (Int, [(Int, Int)])
CloudsSeq001 = (-1,[(1,36),(2,36)])
CloudsSeq002 :: (Int, [(Int, Int)])
CloudsSeq002 = (-2,[(3,36),(4,36)])
CloudsSequences :: [(Int, [(Int, Int)])]
CloudsSequences = [CloudsSeq001, CloudsSeq002]
\ No newline at end of file
module Charlie
/* Charlie the Duck - (C) Copyright 1996-99, by Mike Wiering, Nijmegen. */
/*
COPYRIGHT NOTICE
GRAPHICS BY MIKE WIERING, COPYRIGHT 1996-99, ALL RIGHTS RESERVED.
This game is meant only as a demonstration for the Clean Game Library.
You may create new games based on this source code, however DO NOT use
any of the graphics, instead create your own.
The graphics used in this game are from CHARLIE THE DUCK and CHARLIE II
(a new game, still in development).
*/
import StdProcess
import StdGameDef, StdGame, StdGSt
import GameFunctions
/* 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
DEFAULT_LIVES :== 3
:: GameState
= { curlevel :: Int
, maxlevel :: Int
, titlescreen :: Bool
, statusline :: Bool
, exitcode :: Int
, lives :: Int
, coins :: Int
, diamonds :: Int
, score :: Int
, quit :: Bool
, gameover :: Bool
}
initialGameState = { curlevel = 0
, maxlevel = 3
, titlescreen = False
, statusline = False
, exitcode = EC_NONE
, lives = DEFAULT_LIVES
, coins = 0
, diamonds = 0
, score = 0
, quit = False
, gameover = False
}
EC_NONE :== 0
EC_SUCCESS :== 1
EC_FAILURE :== 2
EC_QUIT :== 3
/* ---------- main program: load game definition and start the game! ---------- */
Start world
= startIO SDI 0 init [ProcessClose closeProcess] world
where
init ps
# (_, ps) = OpenGame initialGameState DuckGame [ColorDepth 16] ps
/* use default mode: 230x240 */
= closeProcess ps
/* ---------- the complete game definition ---------- */
DuckGame :: (Game GameState)
DuckGame =
{ levels = [ TitleScreen
, GameLevel1
, GameLevel2
]
, quitlevel = accGSt QuitFunction
, nextlevel = accGSt NextLevelFunction
, statistics = accGSt Statistics
}
/* if the quit function returns true, the game engine quit the level */
QuitFunction :: GameState -> (Bool, GameState)
QuitFunction gst
= (gst.quit, {gst & quit = False})
/* function that returns the next level to run, 0 = end game */
NextLevelFunction :: GameState -> (Int, GameState)
NextLevelFunction gst =: {curlevel, maxlevel, titlescreen, exitcode, lives, gameover}
| exitcode == EC_QUIT
= (0, gst)
| titlescreen
= (next, {gst & titlescreen = False
, statusline = True
, lives = DEFAULT_LIVES
, curlevel = next})
| exitcode == EC_FAILURE
| lives > 0
= (curlevel, {gst & lives = lives - 1})
= title
| exitcode == EC_SUCCESS
= nextlevel
= title
where
title = (1, {gst & titlescreen = True
, statusline = False
, gameover = False
, curlevel = 1})
nextlevel = if (curlevel + 1 > maxlevel)
title
(next, {gst & curlevel = next})
next = curlevel + 1
/* function that returns text to be displayed */
Statistics :: GameState -> ([Statistic], GameState)
Statistics gst
| gst.titlescreen
= ([ TitleTextShadow, TitleText
, DemoText
, Copyright
, MenuText 0 "Start"
, MenuText 1 "Exit"
], gst)
| gst.statusline
= ([ Lives gst.lives
, Diamonds gst.diamonds
, Coins gst.coins
, Score gst.score
] ++ (if gst.gameover [GameOver] []), gst)
= ([], gst)
/* ---------- definitions of the levels ---------- */
/* default block size */
W :== 20
H :== 16
DEFAULT_SIZE :== {w = W, h = H}
/* layers */
LYR_BACKGROUND :== 1
LYR_FOREGROUND :== 2
LYR_PLAYER :== 3
LYR_INFRONT :== 4
LYR_STATUS :== 10
/* user events */
EV_QUIT_LEVEL :== 1
EV_GAME_OVER :== 2
EV_STOP_BLINKING :== 10
EV_STOP_MOVING :== 11
EV_HEALTH :== 20
/* ---------- objects ---------- */
/* bounds */
BND_MAIN_CHARACTER :== (1 << 0)
BND_POWER_UP :== (1 << 1) /* coins, diamonds, hearts, etc */
BND_BLOCKS :== (1 << 2) /* crates and bounce blocks */
BND_ENEMY :== (1 << 3)
BND_KILL :== (1 << 4)
BND_WATER :== (1 << 5)
BND_ENDING :== (1 << 6)
BND_STAT :== (1 << 7)
/* predefined bounds
BND_MAP_CODES :== (1 << 30)
BND_STATIC_BOUNDS :== (1 << 31)
*/
/* object codes (initialized by code in the bound map) */
OBJ_AUTOINIT :== 0
OBJ_START :== 0x10 /* lower map values are subtypes */
OBJ_STATIC_COIN :== 0x10
OBJ_FALLING_COIN :== 0x11
OBJ_STATIC_DIAMOND :== 0x12
OBJ_FALLING_DIAMOND :== 0x13
OBJ_HEART :== 0x14
OBJ_LIFE :== 0x15
OBJ_CLOUD :== 0x1A
OBJ_PALM :== 0x1B
OBJ_GROUND1 :== 0x1C
OBJ_GROUND2 :== 0x1D
OBJ_GROUND3 :== 0x1E
OBJ_WATER :== 0x1F
OBJ_BOUNCEBLOCK :== 0x20
OBJ_PIN :== 0x22
OBJ_ENEMY :== 0x80
OBJ_BEE :== 0x81
OBJ_FROG :== 0x82
OBJ_INVISIBLE_CRATE :== 0xB0
OBJ_CRATE :== 0xC0
OBJ_MAIN_CHAR :== 0xF0
OBJ_ENDING :== 0xFE
/* objects created during the game */
OBJ_CRATE_PART :== 0x100
OBJ_SPLASH :== 0x101
OBJ_FLASH :== 0x102
OBJ_STAT :== 0x110
GameObjectList = [ AutoInitObject
, MainCharObject
, StaticCoinObject
, FallingCoinObject
, StaticDiamondObject
, FallingDiamondObject
, HeartObject
, LifeObject
, CrateObject
, InvisibleCrateObject
, CratePartObject
, EnemyObject
, BeeObject
, FrogObject
, CloudObject
, PalmFrontObject
, WaterObject
, SplashObject
, BounceBlockObject
, FlashObject
, EndingObject
, StatHeartObject
, BlockInFrontObject OBJ_GROUND1 (InFrontSprite 1)
, BlockInFrontObject OBJ_GROUND2 (InFrontSprite 2)
, BlockInFrontObject OBJ_GROUND3 (InFrontSprite 3)
, PinObject
]
/* ---------- background cloud ---------- */
/*
Because we only have a few little clouds, we will use
objects instead of a complete layer here.
*/
CloudObject
# obj = defaultGameObject OBJ_CLOUD size NoState
# obj = { obj
& sprites = [CloudSprite]
, init = (newinit size NoState)
}
= obj
where
size = {w = 40, h = 24}
newinit size state subtype _ time gs
# pos = case subtype of
1 -> { x = 36, y = 50 }
2 -> { x = 88, y = 28 }
3 -> { x = 240, y = 43 }
# (objrec, gs) = defaultObjectRec subtype pos size time gs
# objrec = { objrec
& options.static = True
, options.ignorelevelbounds = True
, layer = AtLayer LYR_BACKGROUND
}
= ((state, objrec), gs)
/* ---------- palm front object ---------- */
/*
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.
*/
PalmFrontObject
# obj = defaultGameObject OBJ_PALM size NoState
# obj = { obj
& sprites = [PalmSprite 2, PalmSprite 1, PalmSprite 3]
, init = (newinit size NoState)
}
= obj
where
size = {w = 20, h = 32}
newinit size state subtype pos time gs
# (objrec, gs) = defaultObjectRec subtype pos size time gs
# objrec = { objrec
& layer = AtLayer LYR_INFRONT
, offset = {x = 0, y = ~H}
, currentsprite = (subtype + 1)
}
= ((state, objrec), gs)
BlockInFrontObject objtype spr
# obj = defaultGameObject objtype size NoState
# obj = { obj
& sprites = [spr]
, init = (newinit size NoState)
}
= obj
where
size = DEFAULT_SIZE
newinit size state subtype pos time gs
# (objrec, gs) = defaultObjectRec subtype pos size time gs
# objrec = { objrec
& layer = AtLayer LYR_INFRONT
}
= ((state, objrec), gs)
/* ---------- coins and diamonds ---------- */
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
FallingGameItem objecttype sprite
# obj = StaticGameItem objecttype sprite
# obj = { obj
& init = (newinit size NoState)
}
= obj
where
size = DEFAULT_SIZE
newinit size state subtype pos time gs
# pos = {pos & x = if (subtype == 1) (pos.x + W / 2) (pos.x)}
# (objrec, gs) = defaultObjectRec subtype pos size time gs
# xv = case subtype of
11 -> ~1.6
12 -> ~0.8
14 -> 0.8
15 -> 1.6
otherwise -> 0.0
# objrec = { objrec
& acceleration = {rx = 0.0, ry = 1.0 / 16.0}
, speed = {rx = xv, ry = ~1.25 + ((abs xv) / 4.0)}
, slowdown = {fvx = Factor (1.0 / 32.0), fvy = Value 0.0}
, bounce = {fvx = Value 0.0, fvy = Factor (4.0 / 5.0)}
, layer = AtLayer LYR_FOREGROUND
, ownbounds = BND_POWER_UP
, bouncebounds = BND_STATIC_BOUNDS
, collidebounds = BND_MAIN_CHARACTER
, forgetdistance = {x = 8, y = 8}
}
= ((state, objrec), gs)
StaticGameItem objecttype sprite
# obj = defaultGameObject objecttype size NoState
# obj = { obj
& sprites = [sprite, GlitterSprite 25]
, init = (newinit size NoState)
, collide = newcollide
, animation = killobject
}
= obj
where
size = DEFAULT_SIZE
newinit size state subtype pos time gs
# pos = {pos & x = if (subtype == 1) (pos.x + W / 2) (pos.x)}
# (objrec, gs) = defaultObjectRec subtype pos size time gs
# objrec = { objrec
& options.ignorelevelbounds = True
, ownbounds = BND_POWER_UP
, bouncebounds = BND_STATIC_BOUNDS
, collidebounds = BND_MAIN_CHARACTER
, layer = AtLayer LYR_FOREGROUND
}
= ((state, objrec), gs)
newcollide (st, or) bnds objtype objrec gs
| objtype == OBJ_MAIN_CHAR
# (points, gs) = ItemScoreAndSound objecttype gs
# gs = addscore points gs
= ((st, {or & currentsprite = SPR_GLITTER
, options.removemapcode = True
, layer = AtLayer LYR_INFRONT
, ownbounds = 0
, collidebounds = 0
}), gs)
= ((st, or), gs)
ItemScoreAndSound ot gs
# (pan, gs) = RandomPan gs
| (ot == OBJ_STATIC_COIN) || (ot == OBJ_FALLING_COIN)
# (_, gs) = PlaySoundSample SND_COIN DefaultVolume pan (getnotefreq 61) 0 gs
# (_, gs) = PlaySoundSample SND_COIN DefaultVolume pan (getnotefreq 73) 4 gs
= (50, inccoins gs)
| (ot == OBJ_FALLING_DIAMOND) || (ot == OBJ_STATIC_DIAMOND)
# instr = SND_COIN
# (_, gs) = PlaySoundSample instr DefaultVolume pan (getnotefreq 68) 0 gs
# (_, gs) = PlaySoundSample instr DefaultVolume pan (getnotefreq 75) 8 gs
# (_, gs) = PlaySoundSample instr HighVolume pan (getnotefreq 80) 16 gs