TaggedEngine/charts/ugh/script.lua

67 lines
1.5 KiB
Lua

local videoPath = "videos/ughCutscene.ogv"
local song
local videoStream
local video
local random
local module = {}
function module.onCreate(songName)
random = math.random(1, 25)
if not sharedVars.tankmanLoaded then
sharedVars.tankmanLoaded = {}
end
if not sharedVars.tankmanLoaded[random] then
sharedVars.tankmanLoaded[random] = love.audio.newSource(string.format("sounds/week7/death/jeffGameover-%s.ogg", random), "stream")
end
if songName == "Ugh" then
sharedVars.canStart = false
song = songName
videoStream = love.video.newVideoStream(love.filesystem.newFile(videoPath))
videoStream:play()
video = love.graphics.newVideo(videoStream)
video:play()
end
end
function module.onUpdate()
if videoStream then
if not videoStream:isPlaying() then
sharedVars.canStart = true
video = nil
videoStream = nil
else
if love.keyboard.isDown("space") and videoStream and videoStream:isPlaying() then
videoStream:pause()
end
end
end
end
function module.onDraw()
if video then
love.graphics.draw(video, 0,0,0,1.5,1.5)
end
end
function module.onClose()
if video then
video:stop()
video:release()
video = nil
videoStream:stop()
videoStream:release()
videoStream = nil
end
end
function module.onDeath()
sharedVars.tankmanLoaded[random]:play()
end
return module