Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
So I am wondering if anyone is using RPG Maker XP that could help me with inputting a mini-game of DDR like Friday Night Funkin does it since there is a script of a DDR(Dance Dance revolution)in vx Ace so I am wondering is there one in XP or a different method to input a DDR in XP.
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,052
Reaction score
5,708
First Language
English
Primarily Uses
RMVXA
"RGSS Scripts" is for releasing scripts that you have created, so I'll move this over to Script Requests for you.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,923
Reaction score
8,256
First Language
German
Primarily Uses
RMMV
you should give at least some explanation about "what is DDR", or most people won't be able to answer your questions.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
since there is a script of a DDR in vx Ace
Interesting, I didn't know that one existed.
I grabbed the demo and tried to convert it to XP.
I finally got it to not give me errors on the script, but I get a "script is hanging" error when trying to load the scene.
I don't know enough about xp to fix that.

1621262861863.png

DDR (Dance Dance Revolution) script demo here. Made by Shiggy - called Stepmania.

My converted attempt. If someone else knows more of XP then fix it up for the OP.

Ruby:
module Stepmania

  BACKGROUND = "SanzuRiver.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=[]
    $scene = Scene_DDR.new
  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
    while !((l[0][0] == 0 || l[0][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]
    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
    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
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def main
   # super
    Graphics.frame_rate=90.0
    @graphical_offset = (480-$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(640,480)
    @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]
    @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 = [480/arrow_speed,@time_before_input1+16].max
    @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
    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
    Graphics.update
  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
    $scene = Scene_Map.new if Input.trigger?(Input::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,480+100)
    @flawless=0
    @perfect=0
    @great=0
    @good=0
    @bad=0
    @miss=0
    self.contents = Bitmap.new(160 - 32, 480 - 32)
    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
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 120, 32, $stepmania_title)
    self.contents.draw_text(0, 40, 120, 32, "by "+$stepmania_artist)
    self.contents.font.color = system_color
    self.contents.draw_text(0, 80, 120, 32, "Flawless")
    self.contents.draw_text(0, 120, 120, 32, "Perfect")
    self.contents.draw_text(0, 160, 120, 32, "Great")
    self.contents.draw_text(0, 200, 120, 32, "Good")
    self.contents.draw_text(0, 240, 120, 32, "Bad")
    self.contents.draw_text(0, 280, 120, 32, "Miss")
    self.contents.font.color = normal_color
    self.contents.draw_text(80, 80, 36, 32, @flawless.to_s)
    self.contents.draw_text(80, 120, 36, 32, @perfect.to_s)
    self.contents.draw_text(80, 160, 36, 32, @great.to_s)
    self.contents.draw_text(80, 200, 36, 32, @good.to_s)
    self.contents.draw_text(80, 240, 36, 32, @bad.to_s)
    self.contents.draw_text(80, 280, 36, 32, @miss.to_s)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_all_items
    Graphics.update
  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
    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 } 
    @arrows=@hold.compact
    @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
    #@battleback_sprite = Sprite.new(@viewport1)
    @back_sprite = Sprite.new(@viewport1)
    @back_sprite.bitmap = RPG::Cache.battleback(Stepmania::BACKGROUND)
    @back_sprite.src_rect.set(0, 0, 640, 480)
    #@back_sprite.bitmap = self.bitmap = RPG::("Graphics/Battlebacks/", 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 = 320
    sprite.y = 240
  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(@viewport1)
      arrow.bitmap = RPG::Cache.character("ddr_char4",0)
      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=480 - @graphical_offset
    end
    return a
  end
  #--------------------------------------------------------------------------
  # * Free target arrows
  #--------------------------------------------------------------------------
  def dispose_target_arrows
    @target_arrows.each {|sprite| sprite.dispose }
  end

end
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
Interesting, I didn't know that one existed.
I grabbed the demo and tried to convert it to XP.
I finally got it to not give me errors on the script, but I get a "script is hanging" error when trying to load the scene.
I don't know enough about xp to fix that.

View attachment 189552

DDR (Dance Dance Revolution) script demo here. Made by Shiggy - called Stepmania.

My converted attempt. If someone else knows more of XP then fix it up for the OP.

Ruby:
module Stepmania

  BACKGROUND = "SanzuRiver.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=[]
    $scene = Scene_DDR.new
  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
    while !((l[0][0] == 0 || l[0][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]
    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
    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
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def main
   # super
    Graphics.frame_rate=90.0
    @graphical_offset = (480-$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(640,480)
    @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]
    @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 = [480/arrow_speed,@time_before_input1+16].max
    @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
    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
    Graphics.update
  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
    $scene = Scene_Map.new if Input.trigger?(Input::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,480+100)
    @flawless=0
    @perfect=0
    @great=0
    @good=0
    @bad=0
    @miss=0
    self.contents = Bitmap.new(160 - 32, 480 - 32)
    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
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 120, 32, $stepmania_title)
    self.contents.draw_text(0, 40, 120, 32, "by "+$stepmania_artist)
    self.contents.font.color = system_color
    self.contents.draw_text(0, 80, 120, 32, "Flawless")
    self.contents.draw_text(0, 120, 120, 32, "Perfect")
    self.contents.draw_text(0, 160, 120, 32, "Great")
    self.contents.draw_text(0, 200, 120, 32, "Good")
    self.contents.draw_text(0, 240, 120, 32, "Bad")
    self.contents.draw_text(0, 280, 120, 32, "Miss")
    self.contents.font.color = normal_color
    self.contents.draw_text(80, 80, 36, 32, @flawless.to_s)
    self.contents.draw_text(80, 120, 36, 32, @perfect.to_s)
    self.contents.draw_text(80, 160, 36, 32, @great.to_s)
    self.contents.draw_text(80, 200, 36, 32, @good.to_s)
    self.contents.draw_text(80, 240, 36, 32, @bad.to_s)
    self.contents.draw_text(80, 280, 36, 32, @miss.to_s)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_all_items
    Graphics.update
  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
    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 }
    @arrows=@hold.compact
    @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
    #@battleback_sprite = Sprite.new(@viewport1)
    @back_sprite = Sprite.new(@viewport1)
    @back_sprite.bitmap = RPG::Cache.battleback(Stepmania::BACKGROUND)
    @back_sprite.src_rect.set(0, 0, 640, 480)
    #@back_sprite.bitmap = self.bitmap = RPG::("Graphics/Battlebacks/", 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 = 320
    sprite.y = 240
  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(@viewport1)
      arrow.bitmap = RPG::Cache.character("ddr_char4",0)
      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=480 - @graphical_offset
    end
    return a
  end
  #--------------------------------------------------------------------------
  # * Free target arrows
  #--------------------------------------------------------------------------
  def dispose_target_arrows
    @target_arrows.each {|sprite| sprite.dispose }
  end

end
I freaking bless you for trying and converting this into XP and giving it your best and I probably some of my friends who can help out as well just in case. But once again I thank you for this.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
595
Reaction score
262
First Language
PT-BR
Primarily Uses
RM2k3
See if this is a good alternative for you:
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
595
Reaction score
262
First Language
PT-BR
Primarily Uses
RM2k3
Was that error in the demo or in your game?
  • If it was in the demonstration it could be some incompatibility with RGSS10X.DLL (X is the version)
  • If it was in your game it is likely that it came into conflict with another Script or was placed in the wrong way or lacking some graphic resources.
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
Was that error in the demo or in your game?
  • If it was in the demonstration it could be some incompatibility with RGSS10X.DLL (X is the version)
  • If it was in your game it is likely that it came into conflict with another Script or was placed in the wrong way or lacking some graphic resources.
It was in the game I was trying to input and if it is in conflict with another script or a graphic resources then I don't know where it's coming from since I copy and paste everything I need
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
595
Reaction score
262
First Language
PT-BR
Primarily Uses
RM2k3
Create a basic project already using this DDR system and then insert a script at a time that you already have in your project.
So you soon find out which one is generating the conflict.
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
Create a basic project already using this DDR system and then insert a script at a time that you already have in your project.
So you soon find out which one is generating the conflict.
Okay so I found the problem I can't translate it I have to leave it in Spanish which sucks but what can you do but now the other issue to swapping the songs out with the songs I want to use. (Ahhh Scripting and coding will be the death of me)
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
595
Reaction score
262
First Language
PT-BR
Primarily Uses
RM2k3
I understand, I ended up not having time to test the system. I can only use my personal computer on weekends. Good luck.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
swapping the songs out with the songs I want to use.
It looks to me like you just need to make a folder in the graphics\ddr folder for the song.
Then have the music file called musica.mp3
Create the flechas file with the beats you want
and the image for the background for the song.
Then an image for the song with the same name as the ddr\folder in the graphics\pictures folder.
then the event calls the scene for the song, like in the demo.
A lot of work to make the beats line up I'm sure but once you get the hang of it, it shouldn't be too hard.
This is of course of me just looking at the file structure and event script command.
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
It looks to me like you just need to make a folder in the graphics\ddr folder for the song.
Then have the music file called musica.mp3
Create the flechas file with the beats you want
and the image for the background for the song.
Then an image for the song with the same name as the ddr\folder in the graphics\pictures folder.
then the event calls the scene for the song, like in the demo.
A lot of work to make the beats line up I'm sure but once you get the hang of it, it shouldn't be too hard.
This is of course of me just looking at the file structure and event script command.
Thank you for this info, I'll try this out and see what happens
 

Kandi

Villager
Member
Joined
Feb 14, 2018
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVX
So after so much patience, I have finally got it to work and I want to thank my friends on Discord and of course everyone here who helped out in this forum. It was worth the pain and suffering from scripting.
 
Last edited:

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
300
Reaction score
74
First Language
English
Primarily Uses
RMXP
Just in case anybody is interested, I do recall DerVVulfman was also working on another Dance Dance Revolution script.
 

Latest Threads

Latest Posts

Latest Profile Posts

I just did some math and... apparently what seemed to be a little fun gimmick turned out to be an 80+ actors project :kaoswt2:
Yay! the original character contest 3 pack is here!
Both MV and MZ looks very good, congratulation for both RMW and Tkool participant!
I definitely can add these characters to use for my game project.

Steam link
The worst part of game development has to be marketing. Ugh...
May be starting a new job in a month or so. The thought is both exciting and terrifying.
Not like a rollercoaster though. Rollercoasters are just terrifying.
"Merchants don't sell you a product. They sell you something RIGHT NOW. That's all they're selling, the product of having what you want RIGHT NOW and not having to wait for it."

Forum statistics

Threads
112,476
Messages
1,068,547
Members
146,142
Latest member
maaya
Top