84 lines
2.1 KiB
Lua
84 lines
2.1 KiB
Lua
local myTypes = require("modules.types")
|
|
|
|
local cd = math.random(20, 25)
|
|
|
|
local train
|
|
|
|
local trainPassing = false
|
|
local passing
|
|
|
|
local stage = {
|
|
|
|
}
|
|
|
|
function stage.onCreate()
|
|
local bg = myTypes.Image("images/philly/sky.png")
|
|
bg.resize = myTypes.Vector2(1.5, 1.5)
|
|
bg.modifier = 0.1
|
|
bg.position = myTypes.Vector2(-300)
|
|
bg.layer = -10
|
|
|
|
local city = myTypes.Image("images/philly/city.png")
|
|
city.resize = myTypes.Vector2(1.5, 1.5)
|
|
city.modifier = 0.4
|
|
city.position = myTypes.Vector2(-300)
|
|
city.layer = -9
|
|
|
|
local windows = myTypes.Image("images/philly/window.png")
|
|
windows.resize = myTypes.Vector2(1.5, 1.5)
|
|
windows.modifier = 0.4
|
|
windows.position = myTypes.Vector2(-300)
|
|
windows.layer = -8
|
|
|
|
local behindTrain = myTypes.Image("images/philly/behindTrain.png")
|
|
behindTrain.resize = myTypes.Vector2(1.5, 1.5)
|
|
behindTrain.position = myTypes.Vector2(-885)
|
|
behindTrain.layer = -7
|
|
|
|
train = myTypes.Image("images/philly/train.png")
|
|
train.position = myTypes.Vector2(2000, 600)
|
|
train.layer = -6
|
|
|
|
local street = myTypes.Image("images/philly/street.png")
|
|
street.resize = myTypes.Vector2(1.5, 1.5)
|
|
street.position = myTypes.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 = myTypes.Vector2(2000, 600)
|
|
trainPassing = true
|
|
stage.shared.characters.gf:PlayAnimation("hairBlow")
|
|
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
|
|
stage.shared.characters.gf:PlayAnimation("hairFall")
|
|
end
|
|
end
|
|
--interesting
|
|
--[[if not trainPassing then
|
|
passing:stop()
|
|
end]]
|
|
end
|
|
|
|
function stage.onClose()
|
|
passing:stop()
|
|
passing:release()
|
|
passing = nil
|
|
end
|
|
|
|
return stage |