54 lines
2.3 KiB
Text
54 lines
2.3 KiB
Text
-- Forge: a waves track by time, and soundDone. Three rocks come from the left and right spots
|
|
-- in turn a fifth of a second apart from half a second in, two more at a point from a second and
|
|
-- a half, and the bell's clip, played as it spawned, reports its end.
|
|
dofile("Forge/AuthorCompile.singe")
|
|
|
|
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
|
|
|
|
fontSelect(font)
|
|
fontQuality(FONT_QUALITY_BLENDED)
|
|
|
|
dofile(authorBuild("testScripts/author/waves.game", singeGetDataPath() .. "waves.singe"))
|
|
|
|
local gameUpdate = onOverlayUpdate
|
|
local shot = false
|
|
local checked = false
|
|
local began = os.time()
|
|
local PATIENCE = 10 -- Real seconds to wait for the bell: the mixer runs on the real clock, whatever the frame clock does.
|
|
|
|
|
|
function onOverlayUpdate()
|
|
local t = authorTime()
|
|
local r = gameUpdate()
|
|
|
|
colorForeground(255, 255, 255, 255)
|
|
fontPrint(12, 450, string.format("waves %.1fs: %d rocks, made %d, rung %d", t, authorCount("rock"), AUTHOR_VARS.made, AUTHOR_VARS.rung))
|
|
if (t > 1.2) and not shot then
|
|
shot = true
|
|
singeScreenshot()
|
|
end
|
|
if (t > 3) and not checked then
|
|
local rocks = authorEach("rock")
|
|
local xs = {}
|
|
|
|
for _, rock in ipairs(rocks) do
|
|
local x = authorPosition(rock)
|
|
|
|
xs[#xs + 1] = math.floor(x)
|
|
end
|
|
debugPrint(string.format("WAVES RESULT rocks=%d made=%d rung=%d at=%s after=%.1fs", #rocks, AUTHOR_VARS.made, AUTHOR_VARS.rung, table.concat(xs, ","), t))
|
|
if #rocks ~= 5 then debugPrint("WAVES FAIL five rocks should have come, not " .. #rocks) end
|
|
if AUTHOR_VARS.made ~= 5 then debugPrint("WAVES FAIL the spawn rule saw " .. AUTHOR_VARS.made .. " rocks, not 5") end
|
|
if (xs[1] ~= 60) or (xs[2] ~= 660) or (xs[3] ~= 60) then debugPrint("WAVES FAIL the first wave did not come from the spots in turn") end
|
|
if (xs[4] ~= 360) or (xs[5] ~= 360) then debugPrint("WAVES FAIL the second wave did not come at its point") end
|
|
checked = true
|
|
end
|
|
-- The bell's clip ends on the mixer's own clock, which a deterministic run's frames outpace.
|
|
if checked and ((AUTHOR_VARS.rung >= 1) or (os.time() - began >= PATIENCE)) then
|
|
debugPrint(string.format("WAVES RESULT rung=%d after %d real seconds", AUTHOR_VARS.rung, os.time() - began))
|
|
if AUTHOR_VARS.rung < 1 then debugPrint("WAVES FAIL soundDone never came for the bell") end
|
|
singeQuit()
|
|
end
|
|
|
|
return r
|
|
end
|