[SOLVED] Looping image sequence in an old script?

Hey all. I'm not sure if this is the right thread place, if not could someone move it for me?
Anyway, I found this old VXA script by Shiggy, it's the one that puts Stepmania in Ace.

I'm still in awe that someone made this and think it would be a fun addition to a project I'm working on, but the only problem I'm having is that currently the script only supports a still image as a background (which would be fine, but this project has a lot of animation to it and having a still image is pretty jarring...) I've been trying to get it to loop an image sequence instead of say, 5 images?

I know it's possible. With a little assistance from 'it that shall not be named'(AI) I did manage to get an image sequence to play while the game executed. Unfortunately that version of the code did break the way the minigame handles sprites, and I wasn't able to salvage anything from it. The closest I've gotten since is that the minigame works, and is clearly doing something with the background, but the images don't show up at all.

If someone's as weird as I am and wants to try and tackle this with me, here's what I know for sure: The sequence code needs to be housed in the Spriteset_DDR class, possibly with a little support from where the original [BACKGROUND = ""] definition... I don't think anything else needs to (or should be) touched.

Some clarifications:
All backgrounds/images are housed in Graphics/Battlebacks1, and are all the proper format.
The main background, "SanzuRiver1" is the original background included with the script. The image sequence is bg0-bg4.
The still image for the background is set in the original [BACKGROUND = ""] definition, under module. The path for the still image, as well as the image sequence name, are defined in the Spriteset_DDR class.

Here's the OG version of the code:
Ruby:
module Stepmania

  BACKGROUND = "SanzuRiver1.png"
  $stepmania_border_arrow_distance = 36
  $stepmania_upside_down = false
 
 
  def self.song(song_name,speed=1,chart_id=1)
    @song_name=song_name
    @chart_id=chart_id
    @speed=speed
   
     @bpm_value=[]
     @bpm_keys=[]
   
   
    SceneManager.call(Scene_DDR)
  end
 
  def self.speed
    @speed
  end
 
  def self.song_name
    @song_name
  end
 
  def self.read_file
    mode = "r+"
    file = File.open("Audio/Simfile/" +@song_name+".sm", mode)
   
    inputs=[]
    frames=[]
    colors=[]
    measure=0
    measure_inputs=[]

    header_line=nil

    while header_line != "#NOTES:\n"
      header_line = file.readline
      read_header(header_line)
    end

    chart=1

    while header_line != "#NOTES:\n" || chart < @chart_id
      header_line = file.readline
      chart += 1 if header_line == "#NOTES:\n"
    end

    l = file.readline
    while !((l[0] == '0' || l[0] == '1') && l.length == 5) #if the line starts with '0' or '1' and has a length of 5 it should be the start of the song
      l = file.readline
    end

      test=file.readlines
      l = [l]
      test = l + test
   
   

    for line in test
 
      if line[0] != "," && line[0] != ";"
        measure_inputs.push(line)
      else
        tempo = measure_inputs.length/4.0
        measure_inputs.each_index {|j|
          unless measure_inputs[j] == "0000\n"
            inputs.push(measure_inputs[j].delete "\n")
            frames.push(frame_calcul(measure*4+j/tempo))
            colors.push( (j%tempo).to_f/tempo )
          end
        }    
      measure+=1
      measure_inputs=[]
      end
      break if /;/.match(line)
    end
    return [frames,inputs,colors]
  end

  def self.read_header(string)
    title_match=/#TITLE:([^;]+)/.match(string)
    if title_match != nil
      $stepmania_title = title_match[1]
     
    end
   
    artist_match=/#ARTIST:([^;]+)/.match(string)
    if artist_match != nil
      $stepmania_artist = artist_match[1]
    end
   
    offset_match=/#OFFSET:([^;]+)/.match(string)
    if offset_match != nil
      $stepmania_offset = offset_match[1].to_f
    end
   
    music_match=/#MUSIC:([^;]+).ogg/.match(string)
 
    if music_match != nil
     
      $stepmania_music = music_match[1]
     # msgbox_p(music_match)
    end
   
   
    bpms_match=/#BPMS:([^;]+)/.match(string)
    if bpms_match != nil
      bpms_match2=bpms_match[1].scan(/([.0-9]+)/)
      size=bpms_match2.length/2 - 1
      for i in 0..size
        @bpm_keys.push(bpms_match2[2*i][0].to_f*1.0)
        @bpm_value.push(bpms_match2[2*i+1][0].to_f*1.0)
      end
#      msgbox_p(@bpm_keys)
#      msgbox_p(@bpm_value)
    end
 
   
  end

  def self.frame_calcul (beat)
    if beat == 0
      return 0
    end
    frame=0
    bpm_phase_start = 0
    bpm = @bpm_value[0]
    @bpm_keys.each_index { |i|
    if beat > @bpm_keys[i]
      bpm = @bpm_value[i]
      bpm_phase_start = @bpm_keys[i]
     
    end
    }
    #msgbox_p(bpm_phase_start)
    frame += frame_calcul(bpm_phase_start)
    frame += (beat-bpm_phase_start) * 60 * Graphics.frame_rate / bpm
    frame=frame.round(3)
    return(frame)
  end
 
end


#==============================================================================
# ** Scene_DDR
#------------------------------------------------------------------------------
#  This class performs DDR screen processing.
#==============================================================================

class Scene_DDR < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
   
    Graphics.frame_rate=90.0
    @graphical_offset = (Graphics.height-$stepmania_border_arrow_distance).to_f
    @arrow_speed = @graphical_offset/Graphics.frame_rate * Stepmania.speed
    @hold = Array.new(4,false)
    @hold_arrows = Array.new(4,[])
    @bitmap = Bitmap.new(Graphics.width,Graphics.height)
   
    @sprite = Sprite.new
          @sprite.bitmap=@bitmap
          @sprite.x=0
          @sprite.y=0
          @sprite.z=2
   
   
    create_spriteset
   
    file=Stepmania.read_file
    @notes_inputs = file[1]
    @notes_frames = file[0]
    @notes_colors = file[2]
   
#    msgbox_p(@notes_inputs)
   
   
    @time_before_input1 = Graphics.frame_rate/Stepmania.speed
   
    @time_before_input2=@time_before_input1 + $stepmania_offset*Graphics.frame_rate
    @time_before_input1=@time_before_input1.to_i
 
    @time_before_input2=@time_before_input2.to_i
   
    if @time_before_input2 < 0
       @current_frame= @time_before_input2-1
       start_music
     
     
    else  
       @current_frame= -1
    end
    @age_dispose = [Graphics.height/arrow_speed,@time_before_input1+16].max
    #msgbox_p(@age_dispose)
   
   
    @next_note_index=0
    @on_screen_arrows = []
    @on_screen_holds = []
   
    @buffer=[0,0,0,0]
    @score=0
    create_window
   
  end
  #--------------------------------------------------------------------------
  # * Create DDR Window
  #--------------------------------------------------------------------------
  def create_window
    @ddr_window = Window_DDR.new
  end
 
  def graphical_offset
    @graphical_offset
  end
 
  def arrow_speed
    @arrow_speed
  end
 
 
  #--------------------------------------------------------------------------
  # * Post-Start Processing
  #--------------------------------------------------------------------------
  def start_music
 
    bgm = RPG::ME.new($stepmania_music, 100, 100)
    bgm.play
  end
 
 
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_spriteset
    Graphics.frame_rate=60
    RPG::ME.stop
  end

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
   
    super
    @current_frame+=1
    $game_timer.update
 
    if @current_frame == @time_before_input2
      start_music
    end
#    msgbox_p([@current_frame,@time_before_input2])
   
    if next_note_frame.to_i == @current_frame #+ @time_before_input2
     
      create_ddr_input(next_note_input,next_note_frame,next_note_color)  
     # check_hold(next_note_input)
     
      update_note_index
   
    end
    decrease_buffer
   
   
    input_string=check_input
   # update_hold(input_string)
    update_ddr_inputs(input_string)
   
   
    check_cancel
   
   
  end
 
  #--------------------------------------------------------------------------
  # * Create Sprite Set
  #--------------------------------------------------------------------------
  def create_spriteset
    @spriteset = Spriteset_DDR.new(self)
  end
  #--------------------------------------------------------------------------
  # * Get input of the next note
  #--------------------------------------------------------------------------
  def next_note_input
     @notes_inputs[@next_note_index]
  end
  #--------------------------------------------------------------------------
  # * Get frame of the next note
  #--------------------------------------------------------------------------
  def next_note_frame
     @notes_frames[@next_note_index]
   end
 
   def next_note_color
     @notes_colors[@next_note_index]
   end
 
  #--------------------------------------------------------------------------
  # * Update index of the next note
  #--------------------------------------------------------------------------
  def update_note_index
     @next_note_index+=1
   end
  #--------------------------------------------------------------------------
  # * Free Sprite Set
  #--------------------------------------------------------------------------
  def dispose_spriteset
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Check if player is leaving the game
  #--------------------------------------------------------------------------
  def check_cancel
    SceneManager.return if Input.trigger?(:B)  
  end
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def on_screen_arrows
    @on_screen_arrows
  end
 
  #--------------------------------------------------------------------------
  # * Create Input instance
  #--------------------------------------------------------------------------
  def create_ddr_input(input,frame,color)
   
   
   
    holds=Array.new(4,nil)    
    arrows = []
    bitmap_xy=color_coordinates(color)
 
    for i in 0..3
      if input[i]=='1' || input[i]=='2'
        arrow = Sprite.new
        arrow.bitmap = Cache.character("ddr_char4")
        arrow.src_rect = Rect.new(bitmap_xy[0],bitmap_xy[1]+arrow_order(i)*64,64,64)
        arrow.x = 200 + i * 80
        arrow.y = arrow_origin
        arrow.z = 3      
        arrows.push(arrow)
       
       
      end
     
      if input[i]=='2'
          hold = Sprite.new
          hold.bitmap = Bitmap.new(64,Graphics.height+64)
       
          color= Color.new(0,0,255,128)
          rect= Rect.new(16,32,32,Graphics.height)
          hold.bitmap.fill_rect(rect,color)
     
          hold.x = 200 + i * 80
          hold.y = arrow_origin
          hold.z = 2
          holds[i]=hold
          arrows.push(hold)
      end
       
   
     
      if input[i]=='3'
        for ddr_input in @on_screen_holds
          if ddr_input.hold[i]
            for j in 0..3
              ddr_input.update_hold_length(j) if ddr_input.hold[j]
            end
            break
          end
         
        end
      end    
    end
   
    if holds.any? { |hold| hold }
      input_arrows = Game_DDR_Hold.new(@spriteset,input,frame,arrows,holds)  
      @on_screen_holds.push(input_arrows)    
    else
     
      input_arrows = Game_DDR_Input.new(@spriteset,input,frame,arrows)  
      @on_screen_arrows.push(input_arrows)
    end
   
   
  end
 
 
  #--------------------------------------------------------------------------
  # * Update DDR Input (dispose if out of screen)
  #--------------------------------------------------------------------------
  def update_ddr_inputs(input_string)
   
    if @on_screen_arrows[0]!=nil && @on_screen_arrows[0].age > @age_dispose
        @on_screen_arrows[0].dispose
        @on_screen_arrows.delete_at(0)
    end
   
    remove=[]
    @on_screen_holds.each_index { |i|
      if @on_screen_holds[i].age_complete > @age_dispose
        @on_screen_holds[i].true_dispose
        @on_screen_holds[i] = nil
      end
    }
    @on_screen_holds.compact!
   
    i=0
    input_ok=true
    (@on_screen_arrows+@on_screen_holds).each { |input|
     
      input.update(input_string)
      frame_diff=input.age-@time_before_input1
     
      if input.is_hold? && input.no_arrow?
     
        next
      end
     
     
      #  if frame_diff < -5
       
     #   end
        if frame_diff.floor == 16
          @ddr_window.miss_plus unless input.exclude
        end
        frame_diff=frame_diff.abs
        if frame_diff < 16 && input_string!="0000" && input_ok
          if input.compare(input_string)
             input_ok=false
             if frame_diff < 2
               @ddr_window.score_plus3
              elsif frame_diff < 4
                @ddr_window.score_plus2
              elsif frame_diff < 8
                @ddr_window.score_plus1
              elsif frame_diff < 12
                @ddr_window.good_plus
              else
                @ddr_window.bad_plus
              end
            input.dispose
            @on_screen_arrows.delete_at(i) unless input.is_hold?
          #  break
          end
        end
        i+=1
     
    }
     
     
     
  end
 
  def decrease_buffer
    @buffer.each { |x| x=([x-1,0].min) }
  end
 
  def check_input
    inputs=[:LEFT,:DOWN,:UP,:RIGHT]
    input_string=""
    inputs.each_index { |index|
      if Input.trigger?(inputs[index])
        input_string+="1"
        @buffer[index]=5
      elsif @buffer[index] > 0 && Input.press?(inputs[index])
        input_string+="2"
      elsif Input.press?(inputs[index])
        input_string+="3"
      else
        input_string+="0"
      end
    }
    return input_string
  end
 
  def arrow_order(i)
    case i
    when 0
      index = 1
    when 1
      index = 0
    when 2
      index = 3
    when 3
      index = 2
    end
    return index
  end
 
  def color_coordinates(color)
    case color
    when 0.0
      bitmap_x=0
      bitmap_y=0
    when 0.5
      bitmap_x=0
      bitmap_y=256
    when 0.25
      bitmap_x=320
      bitmap_y=0
    when 0.75
      bitmap_x=320
      bitmap_y=0
    else
      bitmap_x=704
      bitmap_y=0
    end
    return [bitmap_x,bitmap_y]
  end

 
 
 
  def arrow_origin
    if $stepmania_upside_down
      a= -64
    else
      a=Graphics.height
    end
    return a
  end

end



#==============================================================================
# ** Window_DDR
#------------------------------------------------------------------------------
#
#
#==============================================================================

class Window_DDR < Window_Base
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0,0,160,Graphics.height+100)
    @flawless=0
    @perfect=0
    @great=0
    @good=0
    @bad=0
    @miss=0
   
    draw_all_items
  end
 
  def score_plus1
    @great+=1
    refresh
  end
 
  def score_plus2
    @perfect+=1
    refresh
  end
 
  def score_plus3
    @flawless+=1
    refresh
  end
 
  def good_plus
    @good+=1
    refresh
  end
 
  def bad_plus
    @bad+=1
    refresh
  end
 
  def miss_plus
    @miss+=1
    refresh
  end
 
  def draw_all_items
   
    draw_text(0, 0, 120, line_height, $stepmania_title)
    draw_text(0, 40, 120, line_height, "by "+$stepmania_artist)
   
    change_color(system_color)
    draw_text(0, 80, 120, line_height, "Flawless")
    draw_text(0, 120, 120, line_height, "Perfect")
    draw_text(0, 160, 120, line_height, "Great")
    draw_text(0, 200, 120, line_height, "Good")
    draw_text(0, 240, 120, line_height, "Bad")
    draw_text(0, 280, 120, line_height, "Miss")
   
    change_color(normal_color)
    draw_text(80, 80, 36, line_height, @flawless)
    draw_text(80, 120, 36, line_height, @perfect)
    draw_text(80, 160, 36, line_height, @great)
    draw_text(80, 200, 36, line_height, @good)
    draw_text(80, 240, 36, line_height, @bad)
    draw_text(80, 280, 36, line_height, @miss)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_all_items
  end
 
end



#==============================================================================
# ** Game_DDR_Input
#------------------------------------------------------------------------------
#
#
#==============================================================================

class Game_DDR_Input
  def initialize(spriteset,input,frame,arrows)
    @arrow_speed=spriteset.arrow_speed
    @input = input
    @age = 0 + frame%1.0
    @arrows = arrows
   
    @include=true

  end
 
  def input
    @input
  end
 
 
 
 
  def update(input_string)
    @age+=1
 
    @arrows.each { |arrow|
        if $stepmania_upside_down
            arrow.y=(@arrow_speed*@age).round
        else
            arrow.y=(Graphics.height-@arrow_speed*@age).round
        end
      }
  end

 
  def age
    @age
  end
 
  def arrows
    @arrows
  end

 
  def compare(string)
    a=false
    for i in 0..3
      if @input[i] == "1"
        if string[i] == "0"
          return false
        elsif string[i] == "2"
          for j in 0..3
            if  @input[j] == "1" && string[j] == "1"
              a= true
            end
          end
          return false unless a
        end
      end
    end
    return true
   
  end
 
  def exclude
    a=true
    for i in 0..3    
      if input[i]=="1" || input[i]=="2"
        a= false
      end
    end
   # msgbox_p(input)
    return a
   
  end
 
  def is_hold?
    return false
  end
 
  def dispose
   
    @input = nil
    @age = nil
    @arrows.each { |sprite| sprite.dispose }
   
  end
 
  #--------------------------------------------------------------------------
  # * Get the order of arrows in the spriteset
  #--------------------------------------------------------------------------
  def arrow_order(i)
    case i
    when 0
      index = 1
    when 1
      index = 0
    when 2
      index = 3
    when 3
      index = 2
    end
    return index
  end
 
end

class Game_DDR_Hold < Game_DDR_Input
 
  def initialize(spriteset,input,frame,arrows,hold)
    super(spriteset,input,frame,arrows)
    @hold  = hold
    @complete = false
    @age_complete=0
    @no_arrow = false
  end
   
  def dispose
    test=@arrows-@hold
    test.each { |sprite| sprite.dispose }
    @[email protected]
    @no_arrow = true
   
  end
 
  def true_dispose
    @arrows.each { |sprite| sprite.dispose }
    @hold.compact.each { |sprite| sprite.dispose unless sprite.disposed?}
    @arrows = nil
    @hold = nil
    @age = nil
    @age_complete = nil
    @complete = nil
    @no_arrow =true
  end
 
  def press_color(i)
    sprite=hold[i]
    if @length
      length= @length
      sprite.bitmap.clear
    else
      length = [@age*@arrow_speed,Graphics.height].min
    end
     
 
    color= Color.new(255,0,255,128)
    rect= Rect.new(16,32,32,length)
    sprite.bitmap.fill_rect(rect,color)
   
  end
 
  def normal_color(i)
    sprite=hold[i]
    if @length
      length= @length
      sprite.bitmap.clear
    else
      length = [@age*@arrow_speed,Graphics.height].min
    end
   
 
    color= Color.new(0,0,255,128)
    rect= Rect.new(16,32,32,length)
    sprite.bitmap.fill_rect(rect,color)
   
  end
 
  def is_hold?
    return true
  end
 
  def complete
    @complete
  end
 
  def age_complete
    @age_complete
  end
 
  def no_arrow?
    @no_arrow
  end
   
  def update(input_string)
    super
   
      @age_complete+=1  if @complete
   
   
    if @no_arrow
       for i in 0..3
          if hold[i]
            if input_string[i]== '2' || input_string[i]== '3'
              press_color(i)
            else
              normal_color(i)
            end
          end
        end
    end
  end
 
  def hold
    return @hold
  end
 
   def update_hold_length(i)
    unless @complete
    length = @age*@arrow_speed
    length = [Graphics.height,length].min
    @length = length
    sprite=hold[i]
    sprite.bitmap=Bitmap.new(64,length)
    color= Color.new(0,0,255,128)
    rect= Rect.new(16,32,32,length)
    sprite.bitmap.fill_rect(rect,color)
    @complete = true
   
     end  
  end
 
 
 
end
#==============================================================================
# ** Spriteset_DDR
#------------------------------------------------------------------------------
#  This class brings together minigame sprites. It's used within the
# Scene_DDR class.
#==============================================================================

class Spriteset_DDR
  attr_reader :timer
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(scene)
   
    @scene = scene
    @timer = 0
    @graphical_offset=scene.graphical_offset
    @arrow_speed=scene.arrow_speed
   
    create_background  
    create_target_arrows
   
  end
 
  def update
    timer +=1
   
  end
 
 
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    dispose_background
    dispose_target_arrows
 
  end
 
  #--------------------------------------------------------------------------
  # * Get arrow speed
  #--------------------------------------------------------------------------
  def arrow_speed
    @arrow_speed
  end
 
 
  #--------------------------------------------------------------------------
  # * Create Background Sprite
  #--------------------------------------------------------------------------
  def create_background
    @back_sprite = Sprite.new
    @back_sprite.bitmap = Cache.load_bitmap("Graphics/Battlebacks1/", Stepmania::BACKGROUND)
    @back_sprite.z = 0
    center_sprite(@back_sprite)
  end
 
  #--------------------------------------------------------------------------
  # * Move Sprite to Screen Center
  #--------------------------------------------------------------------------
  def center_sprite(sprite)
    sprite.ox = sprite.bitmap.width / 2
    sprite.oy = sprite.bitmap.height / 2
    sprite.x = Graphics.width / 2
    sprite.y = Graphics.height / 2
  end
 
  #--------------------------------------------------------------------------
  # * Free Battle Background (Floor) Sprite
  #--------------------------------------------------------------------------
  def dispose_background
    @back_sprite.bitmap.dispose
    @back_sprite.dispose
  end
 
  #--------------------------------------------------------------------------
  # * Create target arrows
  #--------------------------------------------------------------------------
  def create_target_arrows
    #256,128,31,31
   
    arr = []
   
    for i in 0..3
      arrow = Sprite.new
      arrow.bitmap = Cache.character("ddr_char4")
      arrow.src_rect = Rect.new(512,256+i*64,64,64)
      arr.push(arrow)
    end
 
    @target_arrows = [arr[1],arr[0],arr[3],arr[2]]
   
    for i in 0..3
      @target_arrows[i].x = 200 + i * 80
      @target_arrows[i].y = target_arrow_y
      @target_arrows[i].z = 1
    end
  end
 
  def target_arrow_y
    if $stepmania_upside_down
      a=@graphical_offset
    else
      a=Graphics.height - @graphical_offset
    end
    return a
  end
  #--------------------------------------------------------------------------
  # * Free target arrows
  #--------------------------------------------------------------------------
  def dispose_target_arrows
    @target_arrows.each {|sprite| sprite.dispose }
  end
 
 
end

Some of the changes me/friends/ai have tried include these, in the Spriteset_DDR (I'm including 2 versions, but I can't remember if they're different or not):
Ruby:
#==============================================================================
# ** Spriteset_DDR
#------------------------------------------------------------------------------
#  This class brings together minigame sprites. It's used within the
# Scene_DDR class.
#==============================================================================

class Spriteset_DDR
  attr_reader :timer
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(scene)
   
    @scene = scene
    @timer = 0
    @graphical_offset=scene.graphical_offset
    @arrow_speed=scene.arrow_speed
   
    create_background_animation  
    create_target_arrows
   
  end
 
  def update
    timer +=1
    update_background_animation
  end
 
  #--------------------------------------------------------------------------
  # * Create Background Animation
  #--------------------------------------------------------------------------
  def create_background_animation
    @background_sprites = []
    @background_index = 0
    # Replace "background_image_sequence" with the actual name of your image sequence
    prefix = "bg"
    first_index = 0
    last_index = 4 # Change this to the last index of your image sequence
    (first_index..last_index).each do |i|
      sprite = Sprite.new
      sprite.bitmap = Cache.load_bitmap("Graphics/Battlebacks1/", "#{prefix}#{i}.png")
      sprite.z = 0
      center_sprite(sprite)
      @background_sprites.push(sprite)
    end
  end

  #--------------------------------------------------------------------------
  # * Update Background Animation
  #--------------------------------------------------------------------------
  def update_background_animation
    # Dispose of the current sprite and move to the next one
    @background_sprites[@background_index].dispose
    @background_index = (@background_index + 1) % @background_sprites.size
  end
 
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    @background_sprites.each { |sprite| sprite.bitmap.dispose; sprite.dispose }
    dispose_target_arrows
 
  end
 
  #--------------------------------------------------------------------------
  # * Get arrow speed
  #--------------------------------------------------------------------------
  def arrow_speed
    @arrow_speed
  end
 
 
  #--------------------------------------------------------------------------
  # * Create Background Sprite
  #--------------------------------------------------------------------------
  def create_background
    @back_sprite = Sprite.new
    @back_sprite.bitmap = Cache.load_bitmap("Graphics/Battlebacks1/", Stepmania::BACKGROUND)
    @back_sprite.z = 0
    center_sprite(@back_sprite)
  end
 
  #--------------------------------------------------------------------------
  # * Move Sprite to Screen Center
  #--------------------------------------------------------------------------
  def center_sprite(sprite)
    sprite.ox = sprite.bitmap.width / 2
    sprite.oy = sprite.bitmap.height / 2
    sprite.x = Graphics.width / 2
    sprite.y = Graphics.height / 2
  end
 
  #--------------------------------------------------------------------------
  # * Free Battle Background (Floor) Sprite
  #--------------------------------------------------------------------------
  def dispose_background
    @back_sprite.bitmap.dispose
    @back_sprite.dispose
  end
 
  #--------------------------------------------------------------------------
  # * Create target arrows
  #--------------------------------------------------------------------------
  def create_target_arrows
    #256,128,31,31
   
    arr = []
   
    for i in 0..3
      arrow = Sprite.new
      arrow.bitmap = Cache.character("ddr_char4")
      arrow.src_rect = Rect.new(512,256+i*64,64,64)
      arr.push(arrow)
    end
 
    @target_arrows = [arr[1],arr[0],arr[3],arr[2]]
   
    for i in 0..3
      @target_arrows[i].x = 200 + i * 80
      @target_arrows[i].y = target_arrow_y
      @target_arrows[i].z = 1
    end
  end
 
  def target_arrow_y
    if $stepmania_upside_down
      a=@graphical_offset
    else
      a=Graphics.height - @graphical_offset
    end
    return a
  end
  #--------------------------------------------------------------------------
  # * Free target arrows
  #--------------------------------------------------------------------------
  def dispose_target_arrows
    @target_arrows.each {|sprite| sprite.dispose }
  end


Ruby:
#==============================================================================
# ** Spriteset_DDR
#------------------------------------------------------------------------------
#  This class brings together minigame sprites. It's used within the
# Scene_DDR class.
#==============================================================================

class Spriteset_DDR
  attr_reader :timer
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(scene)
    @scene = scene
    @timer = 0
    @graphical_offset = scene.graphical_offset
    @arrow_speed = scene.arrow_speed
    @background_sprite = nil
    @background_index = 0
    @background_frame_counter = 0
    @background_frame_delay = 10 # Change this value to adjust the delay (in frames)

    create_target_arrows
  end

  def update
    timer += 1
    update_background_animation
  end

  #--------------------------------------------------------------------------
  # * Update Background Animation
  #--------------------------------------------------------------------------
  def update_background_animation
    @background_frame_counter += 1
    if @background_frame_counter >= @background_frame_delay
      dispose_background_sprite

      # Load the next frame image and create a new sprite
      @background_index = (@background_index + 1) % 5 # Assuming you have 5 frames (0 to 4)
      @background_sprite = Sprite.new
      @background_sprite.bitmap = Bitmap.new("Graphics/Battlebacks1/bg#{@background_index}.png")
      @background_sprite.z = 0
      center_sprite(@background_sprite)

      @background_frame_counter = 0 # Reset the frame counter
    end
  end

  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    dispose_background_sprite
    dispose_target_arrows
  end

  #--------------------------------------------------------------------------
  # * Dispose Background Sprite
  #--------------------------------------------------------------------------
  def dispose_background_sprite
    if @background_sprite
      @background_sprite.bitmap.dispose
      @background_sprite.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Get arrow speed
  #--------------------------------------------------------------------------
  def arrow_speed
    @arrow_speed
  end
 
 
  #--------------------------------------------------------------------------
  # * Create Background Sprite
  #--------------------------------------------------------------------------
  def create_background
    @back_sprite = Sprite.new
    @back_sprite.bitmap = Cache.load_bitmap("Graphics/Battlebacks1/", Stepmania::BACKGROUND)
    @back_sprite.z = 0
    center_sprite(@back_sprite)
  end
 
  #--------------------------------------------------------------------------
  # * Move Sprite to Screen Center
  #--------------------------------------------------------------------------
  def center_sprite(sprite)
    sprite.ox = sprite.bitmap.width / 2
    sprite.oy = sprite.bitmap.height / 2
    sprite.x = Graphics.width / 2
    sprite.y = Graphics.height / 2
  end
 
  #--------------------------------------------------------------------------
  # * Free Battle Background (Floor) Sprite
  #--------------------------------------------------------------------------
  def dispose_background
    @back_sprite.bitmap.dispose
    @back_sprite.dispose
  end
 
  #--------------------------------------------------------------------------
  # * Create target arrows
  #--------------------------------------------------------------------------
  def create_target_arrows
    #256,128,31,31
   
    arr = []
   
    for i in 0..3
      arrow = Sprite.new
      arrow.bitmap = Cache.character("ddr_char4")
      arrow.src_rect = Rect.new(512,256+i*64,64,64)
      arr.push(arrow)
    end
 
    @target_arrows = [arr[1],arr[0],arr[3],arr[2]]
   
    for i in 0..3
      @target_arrows[i].x = 200 + i * 80
      @target_arrows[i].y = target_arrow_y
      @target_arrows[i].z = 1
    end
  end
 
  def target_arrow_y
    if $stepmania_upside_down
      a=@graphical_offset
    else
      a=Graphics.height - @graphical_offset
    end
    return a
  end
  #--------------------------------------------------------------------------
  # * Free target arrows
  #--------------------------------------------------------------------------
  def dispose_target_arrows
    @target_arrows.each {|sprite| sprite.dispose }
  end

This is pretty much a shot in the dark, but I'm hoping someone has the solution and it's way easier than it looks. I know a few people that would be interested in this as well, as this script is pretty amazing already. It would just be more amazing if the background would do something.
I've been trying to get it to loop an image sequence
Currently set with 3 image names, so just add on what you want and set the timer.
Currently set with 3 image names, so just add on what you want and set the timer.
Oh wow, thank you so much!
This thread is locked due to being reported as solved. If you need it reopened, let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-looping-image-sequence-in-an-old-script.168901/