Port complete. Let the debugging begin!
This commit is contained in:
parent
3eebc5c61a
commit
2a3d70d31d
1 changed files with 271 additions and 71 deletions
|
@ -22,6 +22,7 @@ SCREEN_ON = ON -- Screen being displayed or hidden
|
|||
STATES = {} -- Game engine states
|
||||
STATE = 0 -- Current game state
|
||||
NEXT_STATE = 0 -- Used when we need to assign a new state after a long operation
|
||||
STATE_DATA = "" -- Used when there is data to pass to a future state
|
||||
JPGS = {} -- Loaded JPG images
|
||||
SHOW_JPG = -1 -- If not -1, the id of the JPG to display
|
||||
END_FRAME = -1 -- If not -1, play video until this frame is reached
|
||||
|
@ -46,6 +47,12 @@ STATE_ROOM_18 = 14
|
|||
STATE_PARSER = 15
|
||||
STATE_BOOM = 16
|
||||
STATE_PLAY_AGAIN = 17
|
||||
STATE_BREAK_BOX = 18
|
||||
STATE_WON_BEAR = 19
|
||||
STATE_CHOOSE_PRIZE = 20
|
||||
STATE_WIN_GAME = 21
|
||||
STATE_EXIT_GAME = 22
|
||||
STATE_PUT_WHERE = 23
|
||||
|
||||
-- Apple II 40 column font.
|
||||
fntApple12 = fontLoad(GAME .. "/Fonts/PrintChar21.ttf", 12)
|
||||
|
@ -55,9 +62,11 @@ fntApple12Width = 0 -- We'll figure this out later
|
|||
-- Game Data
|
||||
L = 0 -- Current location
|
||||
NO = 0 -- Number of objects
|
||||
NF = 0 -- Number of furniture
|
||||
NA = "" -- Player's name
|
||||
T = 0 -- Time
|
||||
BK = 0 -- Has read book
|
||||
B = 0 -- Batteries in jammer
|
||||
|
||||
DIRECTIONS = {
|
||||
"NORTH",
|
||||
|
@ -246,6 +255,30 @@ FURNITURE = {
|
|||
}
|
||||
|
||||
|
||||
function getVerbNoun(what)
|
||||
local N = "" -- Noun
|
||||
local V = "" -- Verb
|
||||
local c = ""
|
||||
local t = 0
|
||||
|
||||
-- Split input into verb/noun.
|
||||
for i = 1,string.len(what),1 do
|
||||
c = what:sub(i, i)
|
||||
if c == " " then
|
||||
t = 1
|
||||
else
|
||||
if t == 1 then
|
||||
N = N .. c
|
||||
else
|
||||
V = V .. c
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return V, N
|
||||
end
|
||||
|
||||
|
||||
function onKeyPressed(key, scancode)
|
||||
|
||||
-- Rude exit
|
||||
|
@ -459,9 +492,11 @@ end
|
|||
function resetGameData()
|
||||
L = 1 -- Current location
|
||||
NO = 12 -- Number of objects
|
||||
NF = 3 -- Number of furniture
|
||||
NA = "" -- Player's name
|
||||
T = 0 -- Time
|
||||
BK = 0 -- Has read book
|
||||
B = 0 -- Batteries in jammer
|
||||
end
|
||||
|
||||
|
||||
|
@ -775,29 +810,18 @@ STATES = {
|
|||
local D = 0 -- Direction to go
|
||||
local KW = 0 -- Known word?
|
||||
local R = 0 -- Room to exit to
|
||||
local c = ""
|
||||
local t = 0
|
||||
local t2 = 0
|
||||
|
||||
-- Split input into verb/noun.
|
||||
for i = 1,string.len(what),1 do
|
||||
c = what:sub(i, i)
|
||||
if c == " " then
|
||||
t = 1
|
||||
else
|
||||
if t == 1 then
|
||||
N = N .. c
|
||||
else
|
||||
V = V .. c
|
||||
end
|
||||
end
|
||||
end
|
||||
V, N = getVerbNoun(what)
|
||||
|
||||
STATE = STATE_NONE
|
||||
|
||||
-- And now the fun!
|
||||
if what == "BREAK BOX" then
|
||||
if L == 2 and (what == "BREAK BOX" or what == "PUSH BUTTON" or what == "PRESS BUTTON" or what == "TURN KNOB" or what == "TURN DIAL") then
|
||||
KW = 1
|
||||
-- 53000
|
||||
screenPrint("UH OH, I THINK THAT WAS A MISTAKE.")
|
||||
pioneer(STATE_BREAK_BOX, "FR18722SE/FR18807PL/")
|
||||
end
|
||||
|
||||
if what == "BREAK DOOR" then
|
||||
|
@ -807,7 +831,18 @@ STATES = {
|
|||
|
||||
if V == "DROP" and N ~= "" then
|
||||
KW = 1
|
||||
-- 26000
|
||||
t = 0
|
||||
for i = 1,NO,1 do
|
||||
if (N == OBJECTS[i].NAME or N == "ALL" or N == "EVERYTHING") and OBJECTS[i].LOCATION == 0 then
|
||||
OBJECTS[i].LOCATION = L
|
||||
t = 1
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("YOU CAN'T DROP WHAT YOU AREN'T CARRYING.")
|
||||
else
|
||||
screenPrint("OK.")
|
||||
end
|
||||
end
|
||||
|
||||
if what == "E" or what == "EAST" then
|
||||
|
@ -815,9 +850,33 @@ STATES = {
|
|||
D = 2
|
||||
end
|
||||
|
||||
if V == "EXAMINE" and N ~= "" then
|
||||
if (V == "EXAMINE" or V == "LOOK") and N ~= "" then
|
||||
KW = 1
|
||||
-- 27000
|
||||
t = 0
|
||||
for i = 1,NO,1 do
|
||||
if (OBJECTS[i].LOCATION == 0 or OBJECTS[i].LOCATION = L) and N == OBJECTS[i].NAME then
|
||||
if OBJECTS[i].DESCRIPTION == "" then
|
||||
screenPrint("I SEE NOTHING IMPORTANT.")
|
||||
else
|
||||
screenPrint(OBJECTS[i].DESCRIPTION)
|
||||
end
|
||||
t = 1
|
||||
end
|
||||
end
|
||||
for i = 1,NF,1 do
|
||||
if (FURNITURE[i].LOCATION == 0 or FURNITURE[i].LOCATION = L) and N == FURNITURE[i].NAME then
|
||||
if FURNITURE[i].DESCRIPTION == "" then
|
||||
screenPrint("NOTHING EXTRAORDINARY HERE.")
|
||||
else
|
||||
screenPrint(FURNITURE[i].DESCRIPTION)
|
||||
end
|
||||
t = 1
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("I CAN'T DESCRIBE THAT.")
|
||||
end
|
||||
end
|
||||
|
||||
if V == "FIND" then
|
||||
|
@ -831,17 +890,36 @@ STATES = {
|
|||
|
||||
if V == "GO" then
|
||||
KW = 1
|
||||
-- 19000
|
||||
processGameState(STATE_PARSER, N)
|
||||
end
|
||||
|
||||
if what == "GIVE COINS" and L == 5 then
|
||||
if (what == "GIVE COINS" or what == "PLAY" or what == "SHOOT") and L == 6 then
|
||||
KW = 1
|
||||
-- 43000
|
||||
if OBJECTS[1].LOCATION ~= 0 then
|
||||
screenPrint("THE MAN BEHIND THE COUNTER TELLS")
|
||||
screenPrint("YOU, 'IF YOU WANNA PLAY YOU GOTTA PAY.'")
|
||||
else
|
||||
screenPrint("YOU HAND OVER THE COINS AND PICK")
|
||||
screenPrint("UP THE GUN.")
|
||||
OBJECTS[1].LOCATION = -1
|
||||
pioneer(STATE_WON_BEAR, "FR10960SE/FR11107PL/")
|
||||
end
|
||||
end
|
||||
|
||||
if what == "GIVE TICKET" and L == 16 then
|
||||
if (what == "GIVE TICKET" or what == "SHOW TICKET" or what == "PLAY") and L == 16 then
|
||||
KW = 1
|
||||
-- 48000
|
||||
if OBJECTS[3].LOCATION ~= 0 then
|
||||
screenPrint("YOU CAN'T AFFORD THE GAME.")
|
||||
else
|
||||
screenPrint("YOU HAND OVER THE TICKET AND THROW THE BALL.")
|
||||
-- CHR$(7) three times here
|
||||
screenPrint("IT'S A WINNER.")
|
||||
screenPrint("YOU HAVE A CHOICE OF FOUR PRIZES!")
|
||||
screenPrint("A LAMP, TOWELS, RADIO, OR POSTER.")
|
||||
screenPrint("WHICH DO YOU WANT?")
|
||||
OBJECTS[3].LOCATION = -2
|
||||
NEXT_STATE = STATE_CHOOSE_PRIZE
|
||||
end
|
||||
end
|
||||
|
||||
if V == "HELP" then
|
||||
|
@ -851,12 +929,36 @@ STATES = {
|
|||
|
||||
if what == "I" or what == "INV" or what == "INVENTORY" then
|
||||
KW = 1
|
||||
-- 24000
|
||||
screenPrint("YOU ARE CARRYING:")
|
||||
t = 0
|
||||
for i = 1,NO,1 do
|
||||
if OBJECTS[i].LOCATION == 0 then
|
||||
t = 1
|
||||
screenPrint(OBJECTS[i].NAME)
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("NOTHING.")
|
||||
end
|
||||
end
|
||||
|
||||
if V == "JAM" then
|
||||
if V == "JAM" or what == "USE JAMMER" then
|
||||
KW = 1
|
||||
-- 54000
|
||||
if L ~= 12 then
|
||||
screenPrint("YOU AREN'T IN LINE OF SIGHT WITH")
|
||||
screenPrint("THE ROLLER COASTER.")
|
||||
else
|
||||
if OBJECTS[12].LOCATION ~= 0 then
|
||||
screenPrint("YOU DON'T HAVE A JAMMER.")
|
||||
else
|
||||
if B == 0 then
|
||||
screenPrint("IT DOESN'T WORK, MAYBE IT NEEDS BATTERIES?")
|
||||
else
|
||||
pioneer(STATE_WIN_GAME, "FR12169SE/FR12227PL/")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if V == "KILL" then
|
||||
|
@ -866,17 +968,28 @@ STATES = {
|
|||
|
||||
if what == "LOOK" then
|
||||
KW = 1
|
||||
-- 22000
|
||||
end
|
||||
|
||||
if V == "LOOK" and N ~= "" then
|
||||
KW = 1
|
||||
-- 27000
|
||||
STATE = STATE_LOOK
|
||||
end
|
||||
|
||||
if what == "MAKE JAMMER" then
|
||||
KW = 1
|
||||
-- 55000
|
||||
if BK == 0 then
|
||||
screenPrint("YOU DON'T KNOW HOW.")
|
||||
else
|
||||
if OBJECTS[10].LOCATION ~= 0 then
|
||||
screenPrint("SOMETHING VITAL IS MISSING.")
|
||||
else
|
||||
if OBJECTS[2].LOCATION ~= 0 then
|
||||
screenPrint("YOU DON'T HAVE THE REQUIRED TOOLS.")
|
||||
else
|
||||
screenPrint("CONGRATULATIONS, YOU NOW HAVE A")
|
||||
screenPrint("JAMMER.")
|
||||
OBJECTS[10].LOCATION = -1
|
||||
OBJECTS[12].LOCATION = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if what == "N" or what == "NORTH" then
|
||||
|
@ -889,29 +1002,26 @@ STATES = {
|
|||
screenPrint("TWO BATTERIES JUST FELL")
|
||||
screenPrint("OUT OF THE BACK.")
|
||||
screenPrint("THEY'RE ON THE GROUND.")
|
||||
OBJECT[11].LOCATION = L
|
||||
OBJECTS[11].LOCATION = L
|
||||
end
|
||||
|
||||
if (V == "PUT" or V == "PLACE") and N ~= "" then
|
||||
KW = 1
|
||||
-- 28000
|
||||
t = 0
|
||||
for i = 1,NO,1 do
|
||||
if N == OBJECTS[i].NAME and OBJECTS[i].LOCATION == 0 then
|
||||
t = i
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("YOU AREN'T CARRYING THE " .. N .. ".")
|
||||
else
|
||||
screenPrint("WHERE?")
|
||||
STATE_DATA = N
|
||||
NEXT_STATE = STATE_PUT_WHERE
|
||||
end
|
||||
end
|
||||
|
||||
if V == "PLAY" and L == 6 then
|
||||
KW = 1
|
||||
-- 43000
|
||||
end
|
||||
|
||||
if V == "PLAY" and L == 16 then
|
||||
KW = 1
|
||||
-- 48000
|
||||
end
|
||||
|
||||
if (what == "PUSH BUTTON" or what == "PRESS BUTTON") and L == 2 then
|
||||
KW = 1
|
||||
-- 53000
|
||||
end
|
||||
|
||||
if what == "QUIT" then
|
||||
KW = 1
|
||||
singeQuit()
|
||||
|
@ -924,9 +1034,9 @@ STATES = {
|
|||
BK = 1
|
||||
end
|
||||
|
||||
if what == "READ TICKET" or what == "LOOK TICKET" then
|
||||
if what == "READ TICKET" then
|
||||
KW = 1
|
||||
-- 27000
|
||||
processGameState(STATE_PARSER, "LOOK TICKET")
|
||||
end
|
||||
|
||||
if what == "S" or what == "SOUTH" then
|
||||
|
@ -934,29 +1044,34 @@ STATES = {
|
|||
D = 3
|
||||
end
|
||||
|
||||
if what == "SHOOT" then
|
||||
KW = 1
|
||||
-- 43000
|
||||
end
|
||||
|
||||
if what == "SHOW TICKET" and L == 16 then
|
||||
KW = 1
|
||||
-- 48000
|
||||
end
|
||||
|
||||
if what == "TAKE" and N ~= "" then
|
||||
KW = 1
|
||||
-- 25000
|
||||
end
|
||||
|
||||
if (what == "TURN KNOB" or what == "TURN DIAL") and L == 2 then
|
||||
KW = 1
|
||||
-- 53000
|
||||
end
|
||||
|
||||
if what == "USE JAMMER" then
|
||||
KW = 1
|
||||
-- 54000
|
||||
t = 0
|
||||
t2 = 0
|
||||
for i = 1,NO,1 do
|
||||
if N == OBJECTS[i].NAME and OBJECTS[i].LOCATION == 0 then
|
||||
screenPrint("YOU ALREADY HAVE THE " .. N .. ".")
|
||||
t = -1
|
||||
end
|
||||
if (N == "ALL" or N == "EVERYTHING" or N == OBJECTS[i].NAME) and OBJECTS[i].LOCATION == L)
|
||||
OBJECTS[i].LOCATION = 0
|
||||
t = 1
|
||||
screenPrint(N .. " TAKEN.")
|
||||
end
|
||||
if N == OBJECTS[i].NAME then
|
||||
t2 = 1
|
||||
end
|
||||
end
|
||||
if t == 0 and t2 == 0 then
|
||||
if N ~= "ALL" and N ~= "EVERYTHING" then
|
||||
screenPrint("I CAN'T TAKE THE " .. N .. ".")
|
||||
else
|
||||
screenPrint("THERE IS NOTHING HERE I CAN TAKE.")
|
||||
end
|
||||
end
|
||||
if t == 0 and t2 == 1 then
|
||||
screenPrint("I DON'T SEE IT HERE.")
|
||||
end
|
||||
end
|
||||
|
||||
if what == "VISIT DANCER" then
|
||||
|
@ -1033,6 +1148,91 @@ STATES = {
|
|||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
[STATE_BREAK_BOX] = function(what)
|
||||
screenPrint("YOU SET OFF THE BOMB.")
|
||||
DELAY = 6
|
||||
NEXT_STATE = STATE_PLAY_AGAIN
|
||||
end,
|
||||
|
||||
[STATE_WON_BEAR] = function(what)
|
||||
screenPrint("GOOD SHOOTING.")
|
||||
screenPrint("HE HANDS YOU A TEDDY BEAR.")
|
||||
OBJECTS[8].LOCATION = 0
|
||||
NEXT_STATE = STATE_PARSER
|
||||
end,
|
||||
|
||||
[STATE_CHOOSE_PRIZE] = function(what)
|
||||
local t = 0
|
||||
|
||||
for i = 5,10,1 do
|
||||
if OBJECTS[i].NAME == what then
|
||||
t = 1
|
||||
OBJECTS[i].LOCATION = 0
|
||||
screenPrint("IT'S YOURS.")
|
||||
if what == "RADIO" then
|
||||
pioneer(STATE_PARSER, "FR1234SE/")
|
||||
else
|
||||
NEXT_STATE = STATE_PARSER
|
||||
end
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("")
|
||||
screenPrint("PLEASE ANSWER WITH LAMP, POSTER, RADIO OR TOWELS.")
|
||||
end
|
||||
end,
|
||||
|
||||
[STATE_WON_GAME] = function(what)
|
||||
screenClear()
|
||||
screenPrint("CONGRATULATIONS!")
|
||||
screenPrint("")
|
||||
screenPrint("YOU SAVED THE ROLLER COASTER!")
|
||||
screenPrint("")
|
||||
screenPrint("")
|
||||
screenPrint("ANY KEY TO EXIT.")
|
||||
KEYHIT_ON = ON
|
||||
NEXT_STATE = STATE_EXIT_GAME
|
||||
end,
|
||||
|
||||
[STATE_EXIT_GAME] = function(what)
|
||||
singeQuit()
|
||||
end,
|
||||
|
||||
[STATE_PUT_WHERE] = function(what)
|
||||
local N = "" -- Noun
|
||||
local V = "" -- Verb
|
||||
local t = 0
|
||||
|
||||
V, N = getVerbNoun(what)
|
||||
|
||||
if what == "DOWN" then
|
||||
processGameState(STATE_PARSER, "DROP " .. STATE_DATA)
|
||||
else
|
||||
if V ~= "IN" and V ~= "ON" then
|
||||
screenPrint("I CAN'T DO THAT.")
|
||||
else
|
||||
if N == "FLOOR" or N == "TABLE" then
|
||||
processGameState(STATE_PARSER, "DROP " .. STATE_DATA)
|
||||
else
|
||||
for i = 1,NO,1 do
|
||||
if N == OBJECTS[i].NAME and (OBJECTS[i].LOCATION == L or OBJECTS[i].LOCATION == 0) then
|
||||
t = i
|
||||
end
|
||||
end
|
||||
if t == 0 then
|
||||
screenPrint("THE " .. N .. " ISN'T HERE.")
|
||||
else
|
||||
screenPrint("OK.")
|
||||
if (STATE_DATA == "RADIO" or STATE_DATA == "JAMMER") and N == "BATTERIES" then
|
||||
B = 1
|
||||
end
|
||||
end
|
||||
STATE = STATE_PARSER
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue