singe/testScripts/scene68.singe
2026-09-14 14:20:17 -05:00

75 lines
3 KiB
Text

-- Forge milestone 5, genre one: branching video. A window on the disc answered in time sends
-- the disc to the success clip; one missed sends it to the death clip and takes a life; lives
-- run out, the score goes to the board, the results card shows, a coin and start continue.
dofile("Forge/AuthorCompile.singe")
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
fontSelect(font)
fontQuality(FONT_QUALITY_BLENDED)
-- The master service, stubbed: what is sent is what is checked.
local submitted = {}
function masterSubmitScore(gameId, value, board, meta)
submitted[#submitted + 1] = { value = value, board = board }
end
function masterPump() end
dofile(authorBuild("testScripts/author/fmv.game", singeGetDataPath() .. "fmv.singe"))
local gameUpdate = onOverlayUpdate
local frames = 0
local shots = 0
local moved = false
local continued = false
local jumps = {}
local lastFrame = -1
local before = { taken = 0, missed = 0 }
local GIVE_UP = 1500
function onOverlayUpdate()
local disc = discGetFrame()
frames = frames + 1
-- The disc jumping backward or far forward is a branch being taken.
if (lastFrame >= 0) and ((disc < lastFrame) or (disc > lastFrame + 20)) then
jumps[#jumps + 1] = lastFrame .. ">" .. disc
end
lastFrame = disc
-- Answer the first window, in time; miss the second on purpose.
if (disc >= 130) and (disc < 150) and not moved and (AUTHOR_VARS.taken == 0) then
authorKeyDown(0, SCANCODE.RIGHT.value)
authorKeyUp(0, SCANCODE.RIGHT.value)
moved = true
end
-- Once it is over, a coin and a start continue. What the run counted is kept first, since
-- the restart begins the vars again.
if AUTHOR_VARS.lives <= 0 and not continued and disc >= 385 then
before = { taken = AUTHOR_VARS.taken, missed = AUTHOR_VARS.missed }
authorSwitchDown(SWITCH_COIN1)
authorSwitchUp(SWITCH_COIN1)
authorSwitchDown(SWITCH_START1)
authorSwitchUp(SWITCH_START1)
continued = true
end
local r = gameUpdate()
colorForeground(255, 255, 255, 255)
fontPrint(12, 450, string.format("authored branching video, frame %d, taken %d, missed %d, lives %d", disc, AUTHOR_VARS.taken, AUTHOR_VARS.missed, AUTHOR_VARS.lives))
if (shots == 0 and disc >= 125) or (shots == 1 and AUTHOR_VARS.taken > 0) or (shots == 2 and AUTHOR_VARS.lives <= 0) then
shots = shots + 1
singeScreenshot()
end
if (continued and frames > 60) or (frames > GIVE_UP) then
debugPrint(string.format("FMV RESULT taken=%d missed=%d lives=%d credits=%d submitted=%d jumps=%s", before.taken, before.missed, AUTHOR_VARS.lives, AUTHOR_VARS.credits, #submitted, table.concat(jumps, " ")))
if before.taken ~= 1 then debugPrint("FMV FAIL the first move was not taken") end
if before.missed ~= 3 then debugPrint("FMV FAIL three misses should have spent the lives") end
if #submitted ~= 1 then debugPrint("FMV FAIL the score was not sent once") end
if not continued or AUTHOR_VARS.lives ~= 3 then debugPrint("FMV FAIL the continue did not restart with three lives") end
singeQuit()
end
return r
end