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

51 lines
2 KiB
Text

-- Occluders (FORGE.md): a painted room in 3D with a pillar that is only in the picture. The
-- pillar is an invisible box that writes depth alone, so the picture shows through it and the hero
-- disappears behind it on the way across. Three shots: before, behind, after.
dofile("Forge/AuthorCompile.singe")
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
fontSelect(font)
fontQuality(FONT_QUALITY_BLENDED)
dofile(authorBuild("testScripts/author/painted.game", singeGetDataPath() .. "painted.singe"))
local gameUpdate = onOverlayUpdate
local frames = 0
local shots = 0
local GIVE_UP = 12
function onOverlayUpdate()
local t = authorTime()
local hero = authorEntity("hero")
local hx = authorX(hero)
frames = frames + 1
local r = gameUpdate()
colorForeground(255, 255, 255, 255)
fontPrint(12, 450, string.format("authored painted room, %.1fs, hero x %.1f, pillar %s", t, hx, hero.material and "" or "is an occluder"))
if (shots == 0 and hx > -3.5) or (shots == 1 and hx > -0.3) or (shots == 2 and hx > 3) then
shots = shots + 1
singeScreenshot()
end
if AUTHOR_VARS.across or (t > GIVE_UP) then
local pillar = authorEntity("pillar")
local _, ry, _ = nodeGetRotation(authorEntity("far").node)
debugPrint(string.format("PAINTED RESULT across=%s heroX=%.1f occluderCall=%s pillarMaterial=%s markerYaw=%.0f", tostring(AUTHOR_VARS.across), hx, tostring(type(materialSetOccluder) == "function"), tostring(pillar.material ~= nil), ry))
if math.abs(ry - 90) > 1 then debugPrint("PAINTED FAIL the marker's ry did not reach its node") end
local sx = nodeGetScale(authorEntity("far").node)
local w = authorSize(authorEntity("far"))
debugPrint(string.format("PAINTED the marker's scale of 2 gives node scale %.1f and a counted width of %.1f", sx, w))
if math.abs(sx - 2) > 0.01 then debugPrint("PAINTED FAIL the scale did not reach the node") end
if not AUTHOR_VARS.across then debugPrint("PAINTED FAIL the hero did not cross") end
singeQuit()
end
return r
end