52 lines
1.6 KiB
Text
52 lines
1.6 KiB
Text
-- A rhythm game (FORGE.md's catalogue): notes that fall to a marker, a press inside the window
|
|
-- scoring and one outside missing, over a music layer.
|
|
dofile("Forge/AuthorCompile.singe")
|
|
|
|
local font = fontLoad("Singe/FreeSansBold.ttf", 18)
|
|
|
|
fontSelect(font)
|
|
fontQuality(FONT_QUALITY_BLENDED)
|
|
overlaySetResolution(720, 480)
|
|
|
|
dofile(authorBuild("testScripts/author/rhythm.game", singeGetDataPath() .. "rhythm.singe"))
|
|
|
|
local gameUpdate = onOverlayUpdate
|
|
local frames = 0
|
|
local shots = 0
|
|
local pressed = {}
|
|
local GIVE_UP = 8
|
|
|
|
|
|
function onOverlayUpdate()
|
|
local t = authorTime()
|
|
|
|
frames = frames + 1
|
|
-- Press when a note is at the marker, once per note, and once at nothing.
|
|
for _, note in ipairs(authorEach("note")) do
|
|
if (math.abs(authorY(note) - 400) < 12) and not pressed[note.id] then
|
|
pressed[note.id] = true
|
|
authorKeyDown(0, SCANCODE.SPACE.value)
|
|
authorKeyUp(0, SCANCODE.SPACE.value)
|
|
end
|
|
end
|
|
if frames == 10 then
|
|
authorKeyDown(0, SCANCODE.SPACE.value)
|
|
authorKeyUp(0, SCANCODE.SPACE.value)
|
|
end
|
|
|
|
local r = gameUpdate()
|
|
|
|
colorForeground(255, 255, 255, 255)
|
|
fontPrint(12, 450, string.format("authored rhythm, %.1fs, notes %d, hits %d, misses %d, music %s", t, authorCount("note"), AUTHOR_VARS.hits, AUTHOR_VARS.misses, tostring(musicIsPlaying())))
|
|
if (shots == 0 and t > 1.5) or (shots == 1 and AUTHOR_VARS.hits > 0) then
|
|
shots = shots + 1
|
|
singeScreenshot()
|
|
end
|
|
if t > GIVE_UP then
|
|
debugPrint(string.format("RHYTHM RESULT hits=%d misses=%d score=%d", AUTHOR_VARS.hits, AUTHOR_VARS.misses, AUTHOR_VARS.score))
|
|
if AUTHOR_VARS.hits < 3 then debugPrint("RHYTHM FAIL fewer than three notes were hit") end
|
|
singeQuit()
|
|
end
|
|
|
|
return r
|
|
end
|