Files
PyTaikoGreen/Scripts/bg_objects/donbg/base.lua
T
2026-02-21 13:32:37 -05:00

56 lines
1.3 KiB
Lua

DonBGBase = {}
DonBGBase.__index = DonBGBase
function DonBGBase.new(index, player_num, path)
local self = setmetatable({}, DonBGBase)
self.name = string.format("%d_%d", index-1, player_num)
tex.load_folder(path, string.format("donbg/%s", self.name))
self.bg_texture = tex.get_texture_info(self.name, "background")
self.move = anim.move(3000, {
total_distance = -self.bg_texture.width,
loop = true
})
self.move:start()
self.is_clear = false
self.clear_fade = tex.get_animation(1)
return self
end
function DonBGBase:set_clear(is_clear)
if is_clear and not self.is_clear then
self.is_clear = true
self.clear_fade:start()
end
end
function DonBGBase:update(current_time_ms)
self.move:update(current_time_ms)
self.clear_fade:update(current_time_ms)
end
function DonBGBase:draw_textures(fade, y, frame)
for i = 0, 4 do
tex.draw_texture(self.name, "background", {
frame = frame,
fade = fade,
x = (i * self.bg_texture.width) + self.move.attribute,
y = y
})
end
end
function DonBGBase:draw(y)
y = y or 0
self:draw_textures(1.0, y, 0)
if self.is_clear then
self:draw_textures(self.clear_fade.attribute, y, 1)
end
end
return DonBGBase