Problem with shooting gallery scene.

This commit is contained in:
Scott Duensing 2022-08-08 20:45:26 -05:00
parent 2a3d70d31d
commit f127b96aa6

View file

@ -29,7 +29,7 @@ END_FRAME = -1 -- If not -1, play video until this frame is reached
DELAY = 0 -- How long to sit before next state, in roughly half seconds DELAY = 0 -- How long to sit before next state, in roughly half seconds
-- Game Engine States -- Game Engine States
STATE_NONE = -1 STATE_NONE = 0 -- Lua tables start at 1, so this is an invalid state
STATE_GET_NAME = 1 STATE_GET_NAME = 1
STATE_GOT_NAME = 2 STATE_GOT_NAME = 2
STATE_BOMB_PLANTED = 3 STATE_BOMB_PLANTED = 3
@ -50,7 +50,7 @@ STATE_PLAY_AGAIN = 17
STATE_BREAK_BOX = 18 STATE_BREAK_BOX = 18
STATE_WON_BEAR = 19 STATE_WON_BEAR = 19
STATE_CHOOSE_PRIZE = 20 STATE_CHOOSE_PRIZE = 20
STATE_WIN_GAME = 21 STATE_WON_GAME = 21
STATE_EXIT_GAME = 22 STATE_EXIT_GAME = 22
STATE_PUT_WHERE = 23 STATE_PUT_WHERE = 23
@ -146,7 +146,7 @@ ROOMS = {
EXITS = "Q@@@", EXITS = "Q@@@",
NAME = "THE OBSERVATION TOWER", NAME = "THE OBSERVATION TOWER",
DESCRIPTION = "BELOW, YOU CAN SEE THE WHOLE CARNIVAL. THE TOP OF THE ROLLER COASTER IS IN SIGHT.", DESCRIPTION = "BELOW, YOU CAN SEE THE WHOLE CARNIVAL. THE TOP OF THE ROLLER COASTER IS IN SIGHT.",
VIDEO = "FR8300SE/FR8488PL/" VIDEO = "FR8300SE/FR8458PL/"
}, { }, {
-- M 13 -- M 13
EXITS = "I@G@", EXITS = "I@G@",
@ -186,57 +186,7 @@ ROOMS = {
} }
} }
OBJECTS = { OBJECTS = {} -- Initialized in resetGameData
{
NAME = "COINS",
DESCRIPTION = "TWO DIMES AND A NICKEL",
LOCATION = 4
}, {
NAME = "TOOLKIT",
DESCRIPTION = "IT CONTAINS EVERYTHING NEEDED FOR SMALL ELECTRONIC REPAIRS",
LOCATION = 7
}, {
NAME = "TICKET",
DESCRIPTION = "IT SAYS, 'GOOD FOR 1 FREE GAME AT THE BALL TOSS, COURTESY OF CREATIVE COMPUTING, THE #1 MAGAZINE OF SOFTWARE AND APPLICATIONS.'",
LOCATION = 14
}, {
NAME = "BOOK",
DESCRIPTION = "THE TITLE IS 'RADIO FREQUENCY JAMMING TECHNIQUES.'",
LOCATION = 15
}, {
NAME = "LAMP",
DESCRIPTION = "IT IS VERY GAUDY.",
LOCATION = -1
}, {
NAME = "TOWELS",
DESCRIPTION = "NICE AND FLUFFY.",
LOCATION = -1
}, {
NAME = "POSTER",
DESCRIPTION = "WHOOPIE -- IT'S THE DALLAS CHEERLEADERS.",
LOCATION = -1
}, {
NAME = "BEAR",
DESCRIPTION = "WHEN YOU PUSH THE BUTTON ON ITS BACK, IT SAYS 'I WUV YOU.'",
LOCATION = -1
}, {
NAME = "UNIFORM",
DESCRIPTION = "",
LOCATION = 10
}, {
NAME = "RADIO",
DESCRIPTION = "",
LOCATION = -1
}, {
NAME = "BATTERIES",
DESCRIPTION = "",
LOCATION = -1
}, {
NAME = "JAMMER",
DESCRIPTION = "",
LOCATION = -1
}
}
FURNITURE = { FURNITURE = {
{ {
@ -318,7 +268,6 @@ function onOverlayUpdate()
colorBackground(0, 0, 0, 255) -- The 255 makes this black opaque to hide the blue disc stopped screen. colorBackground(0, 0, 0, 255) -- The 255 makes this black opaque to hide the blue disc stopped screen.
overlayClear() overlayClear()
colorBackground(0, 0, 0, 0) -- Then we set it back to transparent for future rendering. colorBackground(0, 0, 0, 0) -- Then we set it back to transparent for future rendering.
x = (overlayGetWidth() - spriteGetWidth(SHOW_JPG)) * 0.5 x = (overlayGetWidth() - spriteGetWidth(SHOW_JPG)) * 0.5
y = (overlayGetHeight() - spriteGetHeight(SHOW_JPG)) * 0.5 y = (overlayGetHeight() - spriteGetHeight(SHOW_JPG)) * 0.5
if x < 0 then x = 0 end if x < 0 then x = 0 end
@ -330,7 +279,9 @@ function onOverlayUpdate()
end end
if END_FRAME ~= -1 then if END_FRAME ~= -1 then
--debugPrint("Frame " .. discGetFrame() .. " Waiting " .. END_FRAME)
if (discGetFrame() >= END_FRAME) then if (discGetFrame() >= END_FRAME) then
debugPrint("Playback end. Switching to state " .. NEXT_STATE)
discSearch(END_FRAME) discSearch(END_FRAME)
END_FRAME = -1 END_FRAME = -1
STATE = NEXT_STATE STATE = NEXT_STATE
@ -453,6 +404,8 @@ function pioneer(newstate, command)
NEXT_STATE = newstate NEXT_STATE = newstate
end end
debugPrint("Laserdisc " .. command .. " NEXT_STATE " .. NEXT_STATE .. " STATE " .. STATE)
end end
@ -466,6 +419,7 @@ function processGameState(what)
local func = STATES[STATE] local func = STATES[STATE]
if (func) then if (func) then
debugPrint("Firing state " .. STATE .. " with [" .. what .. "]")
func(what) func(what)
end end
@ -476,7 +430,7 @@ function processInput()
-- Send input to processGameState and display on screen. -- Send input to processGameState and display on screen.
if INPUT ~= "" then if INPUT ~= "" then
screenPrint(INPUT) screenPrint(">" .. INPUT)
if NEXT_STATE ~= STATE_NONE then if NEXT_STATE ~= STATE_NONE then
STATE = NEXT_STATE STATE = NEXT_STATE
NEXT_STATE = STATE_NONE NEXT_STATE = STATE_NONE
@ -497,6 +451,58 @@ function resetGameData()
T = 0 -- Time T = 0 -- Time
BK = 0 -- Has read book BK = 0 -- Has read book
B = 0 -- Batteries in jammer B = 0 -- Batteries in jammer
OBJECTS = {
{
NAME = "COINS",
DESCRIPTION = "TWO DIMES AND A NICKEL",
LOCATION = 4
}, {
NAME = "TOOLKIT",
DESCRIPTION = "IT CONTAINS EVERYTHING NEEDED FOR SMALL ELECTRONIC REPAIRS",
LOCATION = 7
}, {
NAME = "TICKET",
DESCRIPTION = "IT SAYS, 'GOOD FOR 1 FREE GAME AT THE BALL TOSS, COURTESY OF CREATIVE COMPUTING, THE #1 MAGAZINE OF SOFTWARE AND APPLICATIONS.'",
LOCATION = 14
}, {
NAME = "BOOK",
DESCRIPTION = "THE TITLE IS 'RADIO FREQUENCY JAMMING TECHNIQUES.'",
LOCATION = 15
}, {
NAME = "LAMP",
DESCRIPTION = "IT IS VERY GAUDY.",
LOCATION = -1
}, {
NAME = "TOWELS",
DESCRIPTION = "NICE AND FLUFFY.",
LOCATION = -1
}, {
NAME = "POSTER",
DESCRIPTION = "WHOOPIE -- IT'S THE DALLAS CHEERLEADERS.",
LOCATION = -1
}, {
NAME = "BEAR",
DESCRIPTION = "WHEN YOU PUSH THE BUTTON ON ITS BACK, IT SAYS 'I WUV YOU.'",
LOCATION = -1
}, {
NAME = "UNIFORM",
DESCRIPTION = "",
LOCATION = 10
}, {
NAME = "RADIO",
DESCRIPTION = "",
LOCATION = -1
}, {
NAME = "BATTERIES",
DESCRIPTION = "",
LOCATION = -1
}, {
NAME = "JAMMER",
DESCRIPTION = "",
LOCATION = -1
}
}
end end
@ -672,7 +678,7 @@ STATES = {
end end
-- Exits -- Exits
for i = 1,4,1 do for i = 1,4,1 do
if ROOMS[L].EXITS:sub(i, 1) ~= "@" then if ROOMS[L].EXITS:sub(i, i) ~= "@" then
exits = exits .. DIRECTIONS[i] .. " " exits = exits .. DIRECTIONS[i] .. " "
end end
end end
@ -815,6 +821,8 @@ STATES = {
V, N = getVerbNoun(what) V, N = getVerbNoun(what)
debugPrint("Parser [" .. V .. "][" .. N .. "]")
STATE = STATE_NONE STATE = STATE_NONE
-- And now the fun! -- And now the fun!
@ -852,10 +860,9 @@ STATES = {
if (V == "EXAMINE" or V == "LOOK") and N ~= "" then if (V == "EXAMINE" or V == "LOOK") and N ~= "" then
KW = 1 KW = 1
-- 27000
t = 0 t = 0
for i = 1,NO,1 do 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].LOCATION == 0 or OBJECTS[i].LOCATION == L) and N == OBJECTS[i].NAME then
if OBJECTS[i].DESCRIPTION == "" then if OBJECTS[i].DESCRIPTION == "" then
screenPrint("I SEE NOTHING IMPORTANT.") screenPrint("I SEE NOTHING IMPORTANT.")
else else
@ -865,7 +872,7 @@ STATES = {
end end
end end
for i = 1,NF,1 do 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].LOCATION == 0 or FURNITURE[i].LOCATION == L) and N == FURNITURE[i].NAME then
if FURNITURE[i].DESCRIPTION == "" then if FURNITURE[i].DESCRIPTION == "" then
screenPrint("NOTHING EXTRAORDINARY HERE.") screenPrint("NOTHING EXTRAORDINARY HERE.")
else else
@ -890,7 +897,8 @@ STATES = {
if V == "GO" then if V == "GO" then
KW = 1 KW = 1
processGameState(STATE_PARSER, N) STATE = STATE_PARSER
processGameState(N)
end end
if (what == "GIVE COINS" or what == "PLAY" or what == "SHOOT") and L == 6 then if (what == "GIVE COINS" or what == "PLAY" or what == "SHOOT") and L == 6 then
@ -903,6 +911,7 @@ STATES = {
screenPrint("UP THE GUN.") screenPrint("UP THE GUN.")
OBJECTS[1].LOCATION = -1 OBJECTS[1].LOCATION = -1
pioneer(STATE_WON_BEAR, "FR10960SE/FR11107PL/") pioneer(STATE_WON_BEAR, "FR10960SE/FR11107PL/")
debugPrint("Asked for state " .. STATE_WON_BEAR)
end end
end end
@ -955,7 +964,7 @@ STATES = {
if B == 0 then if B == 0 then
screenPrint("IT DOESN'T WORK, MAYBE IT NEEDS BATTERIES?") screenPrint("IT DOESN'T WORK, MAYBE IT NEEDS BATTERIES?")
else else
pioneer(STATE_WIN_GAME, "FR12169SE/FR12227PL/") pioneer(STATE_WON_GAME, "FR12169SE/FR12227PL/")
end end
end end
end end
@ -1027,7 +1036,7 @@ STATES = {
singeQuit() singeQuit()
end end
if what == "READ BOOK" and (OBJECT[3].LOCATION == 0 or OBJECT[3].LOCATION == L) then if what == "READ BOOK" and (OBJECTS[3].LOCATION == 0 or OBJECTS[3].LOCATION == L) then
KW = 1 KW = 1
screenPrint("YOU NOW KNOW HOw TO MAKE A") screenPrint("YOU NOW KNOW HOw TO MAKE A")
screenPrint("JAMMER FROM A RADIO.") screenPrint("JAMMER FROM A RADIO.")
@ -1036,7 +1045,8 @@ STATES = {
if what == "READ TICKET" then if what == "READ TICKET" then
KW = 1 KW = 1
processGameState(STATE_PARSER, "LOOK TICKET") STATE = STATE_PARSER
processGameState("LOOK TICKET")
end end
if what == "S" or what == "SOUTH" then if what == "S" or what == "SOUTH" then
@ -1044,7 +1054,7 @@ STATES = {
D = 3 D = 3
end end
if what == "TAKE" and N ~= "" then if (V == "TAKE" or V == "GET") and N ~= "" then
KW = 1 KW = 1
t = 0 t = 0
t2 = 0 t2 = 0
@ -1053,7 +1063,7 @@ STATES = {
screenPrint("YOU ALREADY HAVE THE " .. N .. ".") screenPrint("YOU ALREADY HAVE THE " .. N .. ".")
t = -1 t = -1
end end
if (N == "ALL" or N == "EVERYTHING" or N == OBJECTS[i].NAME) and OBJECTS[i].LOCATION == L) if (N == "ALL" or N == "EVERYTHING" or N == OBJECTS[i].NAME) and OBJECTS[i].LOCATION == L then
OBJECTS[i].LOCATION = 0 OBJECTS[i].LOCATION = 0
t = 1 t = 1
screenPrint(N .. " TAKEN.") screenPrint(N .. " TAKEN.")
@ -1084,11 +1094,11 @@ STATES = {
D = 4 D = 4
end end
if what == "WEAR UNIFORM" and (OBJECT[9].LOCATION == 0 or OBJECT[9].LOCATION == L) then if what == "WEAR UNIFORM" and (OBJECTS[9].LOCATION == 0 or OBJECTS[9].LOCATION == L) then
KW = 1 KW = 1
screenPrint("IT FITS WELL AND MAKES A GOOD") screenPrint("IT FITS WELL AND MAKES A GOOD")
screenPrint("DISGUISE.") screenPrint("DISGUISE.")
OBJECT[9].LOCATION = 0 OBJECTS[9].LOCATION = 0
pioneer(STATE_PARSER, "FR5890SE/") pioneer(STATE_PARSER, "FR5890SE/")
end end
@ -1118,6 +1128,9 @@ STATES = {
if STATE == STATE_NONE then if STATE == STATE_NONE then
NEXT_STATE = STATE_PARSER NEXT_STATE = STATE_PARSER
end end
debugPrint("Parser Exit")
end, end,
[STATE_BOOM] = function(what) [STATE_BOOM] = function(what)
@ -1129,7 +1142,7 @@ STATES = {
[STATE_PLAY_AGAIN] = function(what) [STATE_PLAY_AGAIN] = function(what)
if what == "" then if what == "" then
screenClear() screenPrint("")
screenPrint("IT IS ONE YEAR LATER.") screenPrint("IT IS ONE YEAR LATER.")
screenPrint("THE ROLLER COASTER HAS BEEN REBUILT.") screenPrint("THE ROLLER COASTER HAS BEEN REBUILT.")
screenPrint("THE SABOTEUR PLANS TO DESTROY IT AGAIN.") screenPrint("THE SABOTEUR PLANS TO DESTROY IT AGAIN.")
@ -1160,7 +1173,8 @@ STATES = {
screenPrint("GOOD SHOOTING.") screenPrint("GOOD SHOOTING.")
screenPrint("HE HANDS YOU A TEDDY BEAR.") screenPrint("HE HANDS YOU A TEDDY BEAR.")
OBJECTS[8].LOCATION = 0 OBJECTS[8].LOCATION = 0
NEXT_STATE = STATE_PARSER DELAY = 1
NEXT_STATE = STATE_NONE
end, end,
[STATE_CHOOSE_PRIZE] = function(what) [STATE_CHOOSE_PRIZE] = function(what)
@ -1185,12 +1199,11 @@ STATES = {
end, end,
[STATE_WON_GAME] = function(what) [STATE_WON_GAME] = function(what)
screenClear() screenPrint("")
screenPrint("CONGRATULATIONS!") screenPrint("CONGRATULATIONS!")
screenPrint("") screenPrint("")
screenPrint("YOU SAVED THE ROLLER COASTER!") screenPrint("YOU SAVED THE ROLLER COASTER!")
screenPrint("") screenPrint("")
screenPrint("")
screenPrint("ANY KEY TO EXIT.") screenPrint("ANY KEY TO EXIT.")
KEYHIT_ON = ON KEYHIT_ON = ON
NEXT_STATE = STATE_EXIT_GAME NEXT_STATE = STATE_EXIT_GAME
@ -1208,13 +1221,15 @@ STATES = {
V, N = getVerbNoun(what) V, N = getVerbNoun(what)
if what == "DOWN" then if what == "DOWN" then
processGameState(STATE_PARSER, "DROP " .. STATE_DATA) STATE = STATE_PARSER
processGameState("DROP " .. STATE_DATA)
else else
if V ~= "IN" and V ~= "ON" then if V ~= "IN" and V ~= "ON" then
screenPrint("I CAN'T DO THAT.") screenPrint("I CAN'T DO THAT.")
else else
if N == "FLOOR" or N == "TABLE" then if N == "FLOOR" or N == "TABLE" then
processGameState(STATE_PARSER, "DROP " .. STATE_DATA) STATE = STATE_PARSER
processGameState("DROP " .. STATE_DATA)
else else
for i = 1,NO,1 do for i = 1,NO,1 do
if N == OBJECTS[i].NAME and (OBJECTS[i].LOCATION == L or OBJECTS[i].LOCATION == 0) then if N == OBJECTS[i].NAME and (OBJECTS[i].LOCATION == L or OBJECTS[i].LOCATION == 0) then
@ -1259,7 +1274,7 @@ screenClear()
NEXT_STATE = STATE_NONE NEXT_STATE = STATE_NONE
STATE = STATE_GET_NAME STATE = STATE_GET_NAME
--NA = "SCOTT" NA = "SCOTT"
--STATE = STATE_LOOK STATE = STATE_LOOK
pioneer(STATE, "FR2818SE/") pioneer(STATE, "FR2818SE/")