forked from Yonokid/PyTaikoGreen
98 lines
3.4 KiB
Lua
98 lines
3.4 KiB
Lua
FailAnimation = {}
|
|
FailAnimation.__index = FailAnimation
|
|
|
|
function FailAnimation.new(is_2p)
|
|
local self = setmetatable({}, FailAnimation)
|
|
|
|
self.is_2p = is_2p
|
|
self.idx = is_2p and 1 or 0
|
|
self.name = "in"
|
|
self.frame = 0
|
|
|
|
self.bachio_fade_in = tex.get_animation(46, "game")
|
|
self.bachio_texture_change = tex.get_animation(47, "game")
|
|
self.bachio_fall = tex.get_animation(48, "game")
|
|
self.bachio_move_out = tex.get_animation(49, "game")
|
|
self.bachio_boom_fade_in = tex.get_animation(50, "game")
|
|
self.bachio_boom_scale = tex.get_animation(51, "game")
|
|
self.bachio_up = tex.get_animation(52, "game")
|
|
self.bachio_down = tex.get_animation(53, "game")
|
|
self.text_fade_in = tex.get_animation(54, "game")
|
|
|
|
self.text_fade_in:start()
|
|
self.bachio_fade_in:start()
|
|
self.bachio_texture_change:start()
|
|
self.bachio_fall:start()
|
|
self.bachio_move_out:start()
|
|
self.bachio_boom_fade_in:start()
|
|
self.bachio_boom_scale:start()
|
|
self.bachio_up:start()
|
|
self.bachio_down:start()
|
|
|
|
audio.play_sound("fail", "sound")
|
|
|
|
self.t_fail = tex.get_texture("game/ending_anim/fail")
|
|
self.t_bachio_boom = tex.get_texture("game/ending_anim/bachio_boom")
|
|
self.t_bachio_l_in = tex.get_texture("game/ending_anim/bachio_l_in")
|
|
self.t_bachio_l_fall = tex.get_texture("game/ending_anim/bachio_l_fall")
|
|
self.t_bachio_r_in = tex.get_texture("game/ending_anim/bachio_r_in")
|
|
self.t_bachio_r_fall = tex.get_texture("game/ending_anim/bachio_r_fall")
|
|
|
|
local offset2p = tex.get_skin_config("offset_2p")
|
|
self.offset_2p_y = (offset2p and offset2p.y) or 0
|
|
|
|
return self
|
|
end
|
|
|
|
function FailAnimation:update(current_ms)
|
|
self.bachio_fade_in:update(current_ms)
|
|
self.bachio_texture_change:update(current_ms)
|
|
self.bachio_fall:update(current_ms)
|
|
self.bachio_move_out:update(current_ms)
|
|
self.bachio_boom_fade_in:update(current_ms)
|
|
self.bachio_boom_scale:update(current_ms)
|
|
self.bachio_up:update(current_ms)
|
|
self.bachio_down:update(current_ms)
|
|
self.text_fade_in:update(current_ms)
|
|
|
|
if self.bachio_texture_change.is_finished then
|
|
self.name = "fall"
|
|
self.frame = math.floor(self.bachio_fall.attribute)
|
|
else
|
|
self.frame = math.floor(self.bachio_texture_change.attribute)
|
|
end
|
|
end
|
|
|
|
function FailAnimation:draw()
|
|
tex.draw_texture(self.t_fail, {
|
|
fade = self.text_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
|
|
local ltex = (self.name == "in") and self.t_bachio_l_in or self.t_bachio_l_fall
|
|
local rtex = (self.name == "in") and self.t_bachio_r_in or self.t_bachio_r_fall
|
|
|
|
tex.draw_texture(ltex, {
|
|
frame = self.frame,
|
|
x = -self.bachio_move_out.attribute - (self.bachio_up.attribute / 2),
|
|
y = self.bachio_down.attribute - self.bachio_up.attribute,
|
|
fade = self.bachio_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
tex.draw_texture(rtex, {
|
|
frame = self.frame,
|
|
x = self.bachio_move_out.attribute + (self.bachio_up.attribute / 2),
|
|
y = self.bachio_down.attribute - self.bachio_up.attribute,
|
|
fade = self.bachio_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
|
|
tex.draw_texture(self.t_bachio_boom, {
|
|
scale = self.bachio_boom_scale.attribute,
|
|
center = true,
|
|
y = self.idx * self.offset_2p_y,
|
|
fade = self.bachio_boom_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
end
|