67 lines
1.2 KiB
Text
67 lines
1.2 KiB
Text
-- Lesson 15: The Other Way To Write It. The finished script, exactly as the lesson ends.
|
|
-- Run it with: Singe -R -v Singe/menuBackground.mkv 15-threaded.singe
|
|
local message = ""
|
|
local pressed = false
|
|
|
|
|
|
local function drawFrame()
|
|
overlayClear()
|
|
overlayPrint(2, 2, "Frame " .. discGetFrame())
|
|
overlayPrint(2, 4, message)
|
|
end
|
|
|
|
|
|
local function playTo(frame)
|
|
while discGetFrame() < frame do
|
|
drawFrame()
|
|
singeYield()
|
|
end
|
|
end
|
|
|
|
|
|
local function waitForButton()
|
|
pressed = false
|
|
while not pressed do
|
|
drawFrame()
|
|
singeYield()
|
|
end
|
|
end
|
|
|
|
|
|
local function waitSeconds(seconds)
|
|
local stopTime = singeGetTicks() + seconds * 1000
|
|
|
|
while singeGetTicks() < stopTime do
|
|
drawFrame()
|
|
singeYield()
|
|
end
|
|
end
|
|
|
|
|
|
function onInputPressed(what)
|
|
if what == SWITCH_BUTTON1 then
|
|
pressed = true
|
|
end
|
|
end
|
|
|
|
|
|
function singeMain()
|
|
discSearch(0)
|
|
discPlay()
|
|
playTo(120)
|
|
discPause()
|
|
|
|
message = "Press the space bar to go on."
|
|
waitForButton()
|
|
|
|
message = ""
|
|
discPlay()
|
|
playTo(300)
|
|
discPause()
|
|
|
|
message = "The end."
|
|
waitSeconds(4)
|
|
end
|
|
|
|
|
|
dofile("Singe/Framework.singe")
|