Commit dfcb053f authored by Peter Achten's avatar Peter Achten
Browse files

(MW): removed old stuff for new stuff

parent f04c671d
definition module S1B
import StdEnv, StdGameDef
Static1bBitmap :: GameBitmap
Static1bMap :: [{#Int}]
Static1bSeq001 :: (Int, [(Int, Int)])
Static1bSeq002 :: (Int, [(Int, Int)])
Static1bSeq003 :: (Int, [(Int, Int)])
Static1bSeq004 :: (Int, [(Int, Int)])
Static1bSequences :: [(Int, [(Int, Int)])]
implementation module S1B
import StdEnv, StdGameDef
Static1bBitmap :: GameBitmap
Static1bBitmap
= { bitmapname = "S1B.BMP"
, unitsize = { w = 40, h = 24 }
, dimensions = (8, 2)
, transparent = Just { x = 279, y = 47 }
}
Static1bMap :: [{#Int}]
Static1bMap = [{0,0,0,0,0,0,0,0,0,0},
{0,-2,0,0,0,0,-2,0,0,0},
{0,0,-2,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{4,0,4,5,0,4,6,0,5,7},
{9,10,9,9,11,9,9,10,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9}]
Static1bSeq001 :: (Int, [(Int, Int)])
Static1bSeq001 = (-1,[(1,36),(2,36)])
Static1bSeq002 :: (Int, [(Int, Int)])
Static1bSeq002 = (-2,[(3,38),(8,38)])
Static1bSeq003 :: (Int, [(Int, Int)])
Static1bSeq003 = (-3,[(12,48),(13,48)])
Static1bSeq004 :: (Int, [(Int, Int)])
Static1bSeq004 = (-4,[(14,48),(15,48)])
Static1bSequences :: [(Int, [(Int, Int)])]
Static1bSequences = [Static1bSeq001, Static1bSeq002, Static1bSeq003, Static1bSeq004]
\ No newline at end of file
definition module S2
import StdEnv, StdGameDef
Static2Bitmap :: GameBitmap
Static2Map :: [{#Int}]
Static2Seq001 :: (Int, [(Int, Int)])
Static2Seq002 :: (Int, [(Int, Int)])
Static2Seq003 :: (Int, [(Int, Int)])
Static2Seq004 :: (Int, [(Int, Int)])
Static2Sequences :: [(Int, [(Int, Int)])]
implementation module S2
import StdEnv, StdGameDef
Static2Bitmap :: GameBitmap
Static2Bitmap
= { bitmapname = "S2.BMP"
, unitsize = { w = 40, h = 24 }
, dimensions = (8, 2)
, transparent = Just { x = 319, y = 47 }
}
Static2Map :: [{#Int}]
Static2Map = [{0,0,0,0,0,0,0,0,0,0},
{0,0,-1,0,-3,-1,0,0,0,0},
{0,0,0,0,-4,0,-1,0,0,0},
{3,0,4,5,0,4,6,7,5,8},
{10,11,10,10,11,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10}]
Static2Seq001 :: (Int, [(Int, Int)])
Static2Seq001 = (-1,[(1,36),(2,36)])
Static2Seq002 :: (Int, [(Int, Int)])
Static2Seq002 = (-2,[(9,38),(12,38)])
Static2Seq003 :: (Int, [(Int, Int)])
Static2Seq003 = (-3,[(13,48),(14,48)])
Static2Seq004 :: (Int, [(Int, Int)])
Static2Seq004 = (-4,[(15,48),(16,48)])
Static2Sequences :: [(Int, [(Int, Int)])]
Static2Sequences = [Static2Seq001, Static2Seq002, Static2Seq003, Static2Seq004]
\ No newline at end of file
definition module STAT
import StdEnv, StdGameDef
StatusBitmap :: GameBitmap
StatusMap :: [{#Int}]
StatusSeq001 :: (Int, [(Int, Int)])
StatusSequences :: [(Int, [(Int, Int)])]
implementation module STAT
import StdEnv, StdGameDef
StatusBitmap :: GameBitmap
StatusBitmap
= { bitmapname = "STAT.BMP"
, unitsize = { w = 12, h = 12 }
, dimensions = (26, 1)
, transparent = Just { x = 59, y = 11 }
}
StatusMap :: [{#Int}]
StatusMap = [{1,2,3,4,5,5,-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,-1,-1,-1,-1,-1,-1,-1}]
StatusSeq001 :: (Int, [(Int, Int)])
StatusSeq001 = (-1,[])
StatusSequences :: [(Int, [(Int, Int)])]
StatusSequences = [StatusSeq001]
\ No newline at end of file
definition module SUN
import StdEnv, StdGameDef
SunRiseBitmap :: GameBitmap
SunRiseMap :: [{#Int}]
SunRiseSeq001 :: (Int, [(Int, Int)])
SunRiseSequences :: [(Int, [(Int, Int)])]
implementation module SUN
import StdEnv, StdGameDef
SunRiseBitmap :: GameBitmap
SunRiseBitmap
= { bitmapname = "SUN.BMP"
, unitsize = { w = 40, h = 32 }
, dimensions = (8, 1)
, transparent = Just { x = 79, y = 31 }
}
SunRiseMap :: [{#Int}]
SunRiseMap = [{1,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,-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,-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,-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}]
SunRiseSeq001 :: (Int, [(Int, Int)])
SunRiseSeq001 = (-1,[])
SunRiseSequences :: [(Int, [(Int, Int)])]
SunRiseSequences = [SunRiseSeq001]
\ No newline at end of file
module Sint
/*
Sint Nicolaas '99
Written by Mike Wiering (mike.wiering@cs.kun.nl)
Katholieke Universiteit Nijmegen
For more information, see: http://www.cs.kun.nl/is/sint/
Compile with 4000K heap space (Project, Application options)
*/
import StdEnv, StdIO, StdGameDef, StdGame, StdGSt, notes
import osgame, gst, gameobjectutils, Random
/* import ArgEnv */
import SintGfx /* generated by Tile Studio */
VERSION :== "Sint '99 - Versie 1.0"
/* layers */
LYR_BACKGROUND :== 1
LYR_MIDGROUND :== 2
LYR_FOREGROUND :== 3
LYR_KADO :== 8
LYR_PLAYER :== 9
LYR_INFRONT :== 10
LYR_GLITTER :== 20
LYR_STATUS :== 30
/* main character defaults */
DEFAULT_LIVES :== 3
DEFAULT_TIME :== 250
BONUS_TIME :== 125
TODO :== (5 * (5 + 1))
BONUS_PPN :== 50
EXTRA_PPN :== 15
/* scrolling text positions */
START_MSG :== 340
STOP_MSG :== -340
/* level result codes */
EC_NONE :== 0
EC_SUCCESS :== 1
EC_FAILURE :== 2
EC_QUIT :== 3
FIRST_TIME :== -1000
SHOW_PERS_HIS :== -2000
SHOW_HIS :== -2001
FPS :== 70
FADE :== True
ESC_QUIT :== True
CARDWARE :== False
/* high scores */
HIGH_SCORES_FILE :== "SINT99.HIS"
:: HiS
= { name :: !String
, hiscore :: !Int
}
:: CodedHiS
= { codedhiscore :: !String /* binary representation of name and score */
}
emptyhis = { codedhiscore = "" }
MAX_NUMBER_LEN :== 16
MAX_NAME_LEN :== 32
GRONDTAL :== 10
DecodeHiS :: CodedHiS -> [HiS]
DecodeHiS chis
= decodehis ([c \\ c <-: chis.codedhiscore] ++ ['\n']) "" 0 0
where
decodehis :: [Char] !String !Int !Int -> [HiS]
decodehis [] _ _ _ = []
decodehis [c:cs] s i n
| n < MAX_NUMBER_LEN = decodehis cs s ((i * GRONDTAL) + (toInt c)) (n + 1)
| n < MAX_NAME_LEN + MAX_NUMBER_LEN = decodehis cs (s +++ (if (toInt c == 0) "" (toString c))) i (n + 1)
| otherwise = [{name = s, hiscore = i}: decodehis [c:cs] "" 0 0]
EncodeHiS :: [HiS] -> CodedHiS
EncodeHiS his
# chis = codehis his
= { codedhiscore = {c \\ c <- chis}}
where
codehis :: [HiS] -> [Char]
codehis [] = []
codehis [h:hs] = (codeh h) ++ (codehis hs)
codeh h =: {name, hiscore} = (reverse (addzero (codehiscore hiscore) MAX_NUMBER_LEN)) ++
(addzero [c \\ c <-: name] MAX_NAME_LEN)
codehiscore :: Int -> [Char]
codehiscore 0 = []
codehiscore score
= [toChar (score rem GRONDTAL)] ++ codehiscore (score / GRONDTAL)
addzero :: [Char] Int -> [Char]
addzero c n
| length c < n = (addzero c (n - 1)) ++ [toChar 0]
| otherwise = c
ReadScores :: !String !*Files -> (!(!*File, !CodedHiS), !*Files)
ReadScores filename files
# (exists, file, files) = fopen fpath FReadText files
| exists
# (codedhis, file) = ReadHiS file
= ((file, codedhis), files)
# (_, file, files) = fopen fpath FWriteText files
| otherwise
= ((file, emptyhis), files)
where
fpath = filename
ReadHiS :: !*File -> (!CodedHiS, !*File)
ReadHiS file
| sfend file
= (emptyhis, file)
# (codedhi, file) = freadline file
= ({codedhiscore = codedhi}, file)
WriteScores :: !*File !CodedHiS !*Files -> *Files
WriteScores file codedhis files
# (ok, file) = freopen file FWriteText
| not ok
= snd (fclose file files)
# file = WriteHiS codedhis file
= snd (fclose file files)
where
WriteHiS :: !CodedHiS !*File -> *File
WriteHiS codedhis file
= file <<< codedhis.codedhiscore <<< '\n'
FindScore :: String CodedHiS -> Int
FindScore s codedhis
= findscore s (DecodeHiS codedhis)
where
findscore :: String [HiS] -> Int
findscore _ [] = 0
findscore s [h:hs]
| h.name == s = h.hiscore
| otherwise = findscore s hs
UpdateScore gst
# personalscore = FindScore gst.player gst.codedhis
| (gst.score == 0) || (gst.player == "")
= {gst & pershiscore = personalscore, rank = 10000}
# hislist = DecodeHiS gst.codedhis
# (hislist, newrank) = addscoretolist hislist {name = gst.player, hiscore = gst.score} 1
# gst = {gst & codedhis = EncodeHiS hislist}
= {gst & pershiscore = personalscore, rank = newrank}
where
addscoretolist :: [HiS] HiS Int -> ([HiS], Int)
addscoretolist [] h n = ([h], n)
addscoretolist [x:xs] h n
| h.hiscore > x.hiscore = ([h:[x:xs]], n)
| otherwise
# (newxs, newn) = addscoretolist xs h (n + 1)
= ([x:newxs], newn)
/* the game state definition */
:: GameState
= { curlevel :: !Int /* 1 = title, 2 = level1, 3 = bonus1, 4 = level2, etc */
, maxlevel :: !Int
, titlescreen :: !Bool
, quit :: !Bool
, statusline :: !Bool
, exitcode :: !Int
, lives :: !Int
, ppn :: !Int /* pepernoten */
, time :: !Int
, score :: !Int
, gameover :: !Bool
, bonus :: !Bool
, bonusmsg :: !Int /* current position of scrolling message */
, morningmsg :: !Int
, readymsg :: !Int
, notreadymsg :: !Int
, player :: !String /* player's name */
, codedhis :: !CodedHiS
, pershiscore :: !Int
, rank :: !Int
, cursor :: !Int
, randseed :: !RandomSeed
}
initialGameState = { curlevel = 0
, maxlevel = 5
, titlescreen = True
, quit = False
, statusline = True
, exitcode = EC_NONE
, lives = DEFAULT_LIVES
, ppn = 0
, time = FIRST_TIME
, score = 0
, gameover = False
, bonus = False
, bonusmsg = STOP_MSG
, morningmsg = STOP_MSG
, readymsg = STOP_MSG
, notreadymsg = STOP_MSG
, player = ""
, codedhis = emptyhis
, pershiscore = 0
, rank = 0
, cursor = 0
, randseed = nullRandomSeed
}
/* ---------- main program: load game definition and run the game! ---------- */
Start world
# (randomSeed, world) = getNewRandomSeed world
# initgs = {initialGameState & randseed = randomSeed}
= startIO SDI initgs init [ProcessClose closeProcess] world
where
init ps=:{ls=initgs}
# ((hisfile, codedhis), ps) = accFiles (ReadScores HIGH_SCORES_FILE) ps
# gs = {initgs & codedhis = codedhis}
# (finalgamestate, _, ps) = openGame gs SintGame [ColorDepth depth, ScreenSize {w=320,h=200}] ps
# ps = appFiles (WriteScores hisfile finalgamestate.codedhis) ps
= closeProcess ps
depth = 16
/*
depth = if ((parameter "/8") || (parameter "-8")) 8 16
parameter arg
= checkpar arg getCommandLine 0
where
checkpar arg cmdline n
| n >= (size cmdline) = False
| cmdline.[n] == arg = True
| otherwise = (checkpar arg cmdline (n + 1))
*/
/* ---------- the complete game definition starts here ---------- */
SintGame :: (Game GameState)
SintGame =
{ levels = [ TitleScreen
, Level1
, Level1b
, Level2
, Level2b
]
, quitlevel = accGSt QuitFunction
, nextlevel = accGSt NextLevelFunction
, textitems = accGSt GameTexts
}
/* if the quit function returns true, the game engine quits 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, exitcode, lives, gameover, bonus}
| exitcode == EC_QUIT
= (0, gst)
| (curlevel == 0) || gameover
= title gst
| curlevel == 1 // title screen
= (next, resetgame gst)
| exitcode == EC_FAILURE
| lives > 0
= (curlevel, {(resetlevel gst) & lives = lives - 1})
= title gst
| exitcode == EC_SUCCESS
| not (normallevel curlevel)
# (lev, gst) = nextlevel
= (lev, {gst & bonus = False})
= nextlevel
= title gst
where
resetgame gst
= { resetlevel gst
& titlescreen = False
, statusline = True
, lives = DEFAULT_LIVES
, score = 0
, curlevel = next
}
resetlevel gst
= { gst
& ppn = 0
, time = DEFAULT_TIME
, gameover = False
, bonus = False
}
title gst
# gst = UpdateScore gst
# gst = if (gst.time == FIRST_TIME) gst {gst & time = SHOW_PERS_HIS}
= (1, gsttitle gst)
where
gsttitle gst
= { gst
& titlescreen = True
, statusline = False
, gameover = False
, curlevel = 1
}
nextlevel = if (next > maxlevel)
(title gst)
(next, { gst
& curlevel = next
, time = if (normallevel next) DEFAULT_TIME BONUS_TIME
, bonusmsg = STOP_MSG
, morningmsg = STOP_MSG
, readymsg = STOP_MSG
, notreadymsg = STOP_MSG
})
next
| (normallevel curlevel)
| bonus
= curlevel + 1 // play bonus level
= curlevel + 2 // next (normal) level
= curlevel + 1 // coming from a bonus level, play next level
normallevel n = ((n rem 2) == 0)
/* function that returns text to be displayed */
GameTexts :: GameState -> ([GameText], GameState)
GameTexts gst
| gst.statusline
# (msg, gst) = if (gst.morningmsg > STOP_MSG)
([Morning gst.morningmsg], {gst & morningmsg = gst.morningmsg - 2})
([], gst)
# (msg, gst) = if (gst.bonusmsg > STOP_MSG)
([Bonus gst.bonusmsg], {gst & bonusmsg = gst.bonusmsg - 2})
(msg, gst)