local DonBGBase = require("background/bg_objects/donbg/base") DonBG5 = setmetatable({}, { __index = DonBGBase }) DonBG5.__index = DonBG5 function DonBG5.new(index, player_num, path) local self = setmetatable({}, DonBG5) local base = DonBGBase.new(index, player_num, path) for k, v in pairs(base) do self[k] = v end self.bounce_up = tex.get_animation(4) self.bounce_down = tex.get_animation(5) self.bounce_up:start() self.bounce_down:start() self.adjust = tex.get_animation(8) self.overlay_texture = tex.get_texture_info(self.name, "overlay") self._id_overlay = tex.get_id(self.name, "overlay") or 0 return self end function DonBG5:update(current_time_ms) DonBGBase.update(self, current_time_ms) self.bounce_up:update(current_time_ms) self.bounce_down:update(current_time_ms) if self.bounce_down.is_finished then self.bounce_up:restart() self.bounce_down:restart() end self.adjust:update(current_time_ms) end function DonBG5:draw_textures(fade, y, frame) for i = 0, 5 do tex.draw_id(self._id_bg, { frame = frame, fade = fade, x = (i * self.bg_texture.width) + self.move.attribute, y = y }) tex.draw_id(self._id_overlay, { frame = frame, fade = fade, x = (i * self.bg_texture.width) + self.move.attribute, y = self.bounce_up.attribute - self.bounce_down.attribute - self.adjust.attribute + y }) end end return DonBG5