Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Animated Character in Menu

Hey guys.
I've been looking for a script and have had zero luck so I'm hoping you guys could help me.

Alright, so I'm looking for an XP script that animates the character graphics in the Main menu so that the characters
appear to be walking in place. This would be for any and all characters in the party at any given time.

Hope to hear from someone soon.
:)
 

khmp

Sponsor

Code:
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     frame : frame of animation we want to draw.
  #--------------------------------------------------------------------------
  def draw_actor_graphic_anim(actor, x, y, frame = 0)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0 + (frame * bitmap.width / 4), 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
end

#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  FRAME_UPDATE = 10
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias pasq_animatedchar_window_menustatus_initialize initialize
  alias pasq_animatedchar_window_menustatus_update update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    pasq_animatedchar_window_menustatus_initialize
    @update_in = FRAME_UPDATE
    @step = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh                                                      !OVERRIDE!
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic_anim(actor, x - 40, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                    !ALIAS!
  #--------------------------------------------------------------------------
  def update
    pasq_animatedchar_window_menustatus_update
    
    # Update timer.
    @update_in -= 1
    
    # If the timer has run it's course.
    if @update_in == 0
      # Update which step we are on.
      @step += 1
      # Reset the step if necessary.
      @step = 0 if @step == 4
      # Reset the timer.
      @update_in = FRAME_UPDATE
      
      clear = Color.new(0, 0, 0, 0)
      
      # Draw the animated frames.
      for i in 0...$game_party.actors.size
        actor, x, y = $game_party.actors[i], 24, i * 116
        self.contents.fill_rect(0, y, 64, 64, clear)
        draw_actor_graphic_anim(actor, x, y + 80, @step)
      end
    end
  end
end

I hope that helps. To install the script create a new section above "Main" in the script listings and insert into the empty section the code above.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top