-- A maze (FORGE.md's catalogue): a tile map for the walls, corridors that are a walk area, a -- hero sent by a click, dots eaten on touch, and a ghost that follows the hero across the mesh. dofile("Forge/AuthorCompile.singe") local font = fontLoad("Singe/FreeSansBold.ttf", 18) fontSelect(font) fontQuality(FONT_QUALITY_BLENDED) overlaySetResolution(720, 480) dofile(authorBuild("testScripts/author/maze.game", singeGetDataPath() .. "maze.singe")) local gameUpdate = onOverlayUpdate local frames = 0 local shots = 0 local gapStart = nil local GIVE_UP = 25 function onOverlayUpdate() local t = authorTime() local hero = authorEntity("hero") local ghost = authorEntity("ghost") local gap = authorDistance(hero, ghost) frames = frames + 1 gapStart = gapStart or gap if frames == 10 then -- A click at the far end of the top corridor. authorSetPointer(1, 340, 180, true) authorSwitchDown(SWITCH_BUTTON3) authorSwitchUp(SWITCH_BUTTON3) end local r = gameUpdate() colorForeground(255, 255, 255, 255) fontPrint(12, 450, string.format("authored maze, %.1fs, hero %.0f,%.0f, ghost gap %.0f, eaten %d", t, authorX(hero), authorY(hero), gap, AUTHOR_VARS.eaten)) if (shots == 0 and t > 0.5) or (shots == 1 and AUTHOR_VARS.eaten > 0) then shots = shots + 1 singeScreenshot() end if (AUTHOR_VARS.eaten >= 2 and gap < gapStart - 50) or (t > GIVE_UP) then debugPrint(string.format("MAZE RESULT eaten=%d gap=%.0f (from %.0f) caught=%s after=%.1fs", AUTHOR_VARS.eaten, gap, gapStart, tostring(AUTHOR_VARS.caught), t)) if AUTHOR_VARS.eaten < 2 then debugPrint("MAZE FAIL the hero did not eat two dots on its way") end if gap >= gapStart - 50 then debugPrint("MAZE FAIL the ghost did not close on the hero") end singeQuit() end return r end