71 lines
2.4 KiB
Text
71 lines
2.4 KiB
Text
-- Forge milestone 1, genre one: the shoot-em-up. Kinds spawned and destroyed by the dozen,
|
|
-- collision events between types, health and death, a spawner, a HUD document bound to vars, a
|
|
-- sequence (say waits), a flash, and a game over -- driven by what the game is doing.
|
|
dofile("Forge/AuthorCompile.singe")
|
|
|
|
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
|
|
|
|
fontSelect(font)
|
|
fontQuality(FONT_QUALITY_BLENDED)
|
|
overlaySetResolution(720, 480)
|
|
|
|
dofile(authorBuild("testScripts/author/shmup.game", singeGetDataPath() .. "shmup.singe"))
|
|
|
|
local gameUpdate = onOverlayUpdate
|
|
local frames = 0
|
|
local shots = 0
|
|
local maxRaiders = 0
|
|
local maxShots = 0
|
|
local reported = false
|
|
local GIVE_UP = 30
|
|
|
|
|
|
function onOverlayUpdate()
|
|
local t = authorTime()
|
|
local ship = authorEntity("ship")
|
|
|
|
frames = frames + 1
|
|
-- Hold fire from the start and sweep left and right under the spawn points.
|
|
if frames == 2 then
|
|
authorKeyDown(0, SCANCODE.SPACE.value)
|
|
end
|
|
if ship then
|
|
local x = authorX(ship)
|
|
|
|
if (x > 500) and authorKeyHeld(SCANCODE.RIGHT.value) then
|
|
authorKeyUp(0, SCANCODE.RIGHT.value)
|
|
authorKeyDown(0, SCANCODE.LEFT.value)
|
|
elseif (x < 120) and authorKeyHeld(SCANCODE.LEFT.value) then
|
|
authorKeyUp(0, SCANCODE.LEFT.value)
|
|
authorKeyDown(0, SCANCODE.RIGHT.value)
|
|
elseif not (authorKeyHeld(SCANCODE.LEFT.value) or authorKeyHeld(SCANCODE.RIGHT.value)) then
|
|
authorKeyDown(0, SCANCODE.RIGHT.value)
|
|
end
|
|
end
|
|
|
|
local r = gameUpdate()
|
|
|
|
maxRaiders = math.max(maxRaiders, authorCount("raider"))
|
|
maxShots = math.max(maxShots, authorCount("shot"))
|
|
colorForeground(255, 255, 255, 255)
|
|
fontPrint(12, 450, string.format("authored shmup, %.1fs, raiders %d, shots %d, score %d, lives %d", t, authorCount("raider"), authorCount("shot"), AUTHOR_VARS.score, AUTHOR_VARS.lives))
|
|
|
|
if (shots == 0 and t > 1.5) or (shots == 1 and t > 4) or (shots == 2 and AUTHOR_VARS.cleared) then
|
|
shots = shots + 1
|
|
singeScreenshot()
|
|
end
|
|
if (AUTHOR_VARS.cleared and t > 1 and not reported) or (t > GIVE_UP) then
|
|
reported = true
|
|
debugPrint(string.format("SHMUP RESULT score=%d lives=%d cleared=%s maxRaiders=%d maxShots=%d after=%.1fs",
|
|
AUTHOR_VARS.score, AUTHOR_VARS.lives, tostring(AUTHOR_VARS.cleared), maxRaiders, maxShots, t))
|
|
if maxRaiders < 3 then
|
|
debugPrint("SHMUP FAIL the spawner never had three raiders up at once")
|
|
end
|
|
if AUTHOR_VARS.score <= 0 then
|
|
debugPrint("SHMUP FAIL nothing was ever hit")
|
|
end
|
|
singeQuit()
|
|
end
|
|
|
|
return r
|
|
end
|