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

43 lines
1.3 KiB
Text

-- Bowling (FORGE.md's catalogue): a ball shoved down a lane by a press, pins that are bodies
-- counted as they fall, and a trigger at the end of the lane.
dofile("Forge/AuthorCompile.singe")
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
fontSelect(font)
fontQuality(FONT_QUALITY_BLENDED)
dofile(authorBuild("testScripts/author/bowling.game", singeGetDataPath() .. "bowling.singe"))
local gameUpdate = onOverlayUpdate
local frames = 0
local shots = 0
local GIVE_UP = 20
function onOverlayUpdate()
local t = authorTime()
local ball = authorEntity("ball")
frames = frames + 1
if frames == 5 then
authorKeyDown(0, SCANCODE.SPACE.value)
authorKeyUp(0, SCANCODE.SPACE.value)
end
local r = gameUpdate()
colorForeground(255, 255, 255, 255)
fontPrint(12, 450, string.format("authored bowling, %.1fs, ball z %.1f, pins down %d", t, authorField(ball, "z"), AUTHOR_VARS.down))
if (shots == 0 and t > 0.5) or (shots == 1 and AUTHOR_VARS.down > 0) then
shots = shots + 1
singeScreenshot()
end
if (AUTHOR_VARS.done and t > 3) or (t > GIVE_UP) then
debugPrint(string.format("BOWL RESULT down=%d done=%s ballZ=%.1f after=%.1fs", AUTHOR_VARS.down, tostring(AUTHOR_VARS.done), authorField(ball, "z"), t))
if AUTHOR_VARS.down < 1 then debugPrint("BOWL FAIL no pin fell") end
singeQuit()
end
return r
end