TaggedEngine/stages/philly.lua
2025-07-04 19:02:19 +07:00

88 lines
2.2 KiB
Lua

local cd = math.random(20, 25)
local train
local trainPassing = false
local passing
local stage = {
}
function stage.onCreate()
local bg = Image("images/philly/sky.png")
bg.resize = Vector2(1.5, 1.5)
bg.modifier = 0.1
bg.position = Vector2(-300)
bg.layer = -10
local city = Image("images/philly/city.png")
city.resize = Vector2(1.5, 1.5)
city.modifier = 0.4
city.position = Vector2(-300)
city.layer = -9
local windows = Image("images/philly/window.png")
windows.resize = Vector2(1.5, 1.5)
windows.modifier = 0.4
windows.position = Vector2(-300)
windows.layer = -8
local behindTrain = Image("images/philly/behindTrain.png")
behindTrain.resize = Vector2(1.5, 1.5)
behindTrain.position = Vector2(-885)
behindTrain.layer = -7
train = Image("images/philly/train.png")
train.position = Vector2(2000, 600)
train.layer = -6
local street = Image("images/philly/street.png")
street.resize = Vector2(1.5, 1.5)
street.position = Vector2(-885)
street.layer = -5
passing = love.audio.newSource("sounds/philly/train_passes.ogg", "static")
end
function stage.onBeat(beat)
if not trainPassing then
passing:stop()
cd = cd - 1
if cd == 0 then
cd = math.random(20, 25)
train.position = Vector2(2000, 600)
trainPassing = true
if sharedVars.characters.gf then
sharedVars.characters.gf:PlayAnimation("hairBlow")
end
end
end
end
function stage.onUpdate(dt)
if trainPassing then
train.position.x = train.position.x - 5000 * dt
--passing:play()
if train.position.x < -4000 then
trainPassing = false
if sharedVars.characters.gf then
sharedVars.characters.gf:PlayAnimation("hairFall")
end
end
end
--interesting
--[[if not trainPassing then
passing:stop()
end]]
end
function stage.onClose()
passing:stop()
passing:release()
passing = nil
end
return stage