49 lines
1.4 KiB
Text
49 lines
1.4 KiB
Text
-- The long tail (FORGE.md milestone 7), in 3D: a body floating in water, a boat under its
|
|
-- propeller, and a soft body.
|
|
dofile("Forge/AuthorCompile.singe")
|
|
|
|
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
|
|
|
|
fontSelect(font)
|
|
fontQuality(FONT_QUALITY_BLENDED)
|
|
|
|
dofile(authorBuild("testScripts/author/pool.game", singeGetDataPath() .. "pool.singe"))
|
|
|
|
local gameUpdate = onOverlayUpdate
|
|
local frames = 0
|
|
local shots = 0
|
|
local boatStart = nil
|
|
local lowest = math.huge
|
|
|
|
|
|
function onOverlayUpdate()
|
|
local t = authorTime()
|
|
local ball = authorEntity("ball")
|
|
local boat = authorEntity("boat")
|
|
local by = authorY(ball)
|
|
|
|
frames = frames + 1
|
|
boatStart = boatStart or authorField(boat, "z")
|
|
if t > 2 then
|
|
lowest = math.min(lowest, by)
|
|
end
|
|
|
|
local r = gameUpdate()
|
|
|
|
colorForeground(255, 255, 255, 255)
|
|
fontPrint(12, 450, string.format("authored pool, %.1fs, ball y %.2f, boat z %.1f", t, by, authorField(boat, "z")))
|
|
if (shots == 0 and t > 1) or (shots == 1 and t > 4) then
|
|
shots = shots + 1
|
|
singeScreenshot()
|
|
end
|
|
if t > 6 then
|
|
local moved = boatStart - authorField(boat, "z")
|
|
|
|
debugPrint(string.format("POOL RESULT ballLowest=%.2f ballNow=%.2f boatMoved=%.1f balloon=%s", lowest, by, moved, tostring(authorEntity("balloon") ~= nil)))
|
|
if lowest < -1.5 then debugPrint("POOL FAIL the ball sank to the bottom") end
|
|
if moved < 2 then debugPrint("POOL FAIL the boat did not move") end
|
|
singeQuit()
|
|
end
|
|
|
|
return r
|
|
end
|