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.

Extra character frames?

I have already asked for help in the RGSS Support section, but I was directed here. I'm looking for a script that allows you to have more than four frames so that when the characters walk/run it is alot more smoother and natural. If anyone knows where I can find one or someone could make one that would be great!
CREDIT WILL BE GIVEN!
 
I wrote a script for this some time ago.  The trick is that it affects not only your actors but all events if desired. 

Here is the code
Code:
class Game_Temp
  attr_accessor :new_frame_count

  alias more_frame_temp_init initialize

  def initialize
    more_frame_temp_init
    @new_frame_count = 4
  end
end

class Game_Character
  def update
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    if @anime_count > 18 - @move_speed * 2
      if not @step_anime and @stop_count > 0
        @pattern = @original_pattern
      else
        if self.is_a?(Game_Event)
          @pattern = (@pattern + 1) % 4
        else
          @pattern = (@pattern + 1) % $game_temp.new_frame_count
        end
      end
      @anime_count = 0
    end
    if @wait_count > 0
      @wait_count -= 1
      return
    end
    if @move_route_forcing
      move_type_custom
      return
    end
    if @starting or lock?
      return
    end
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      case @move_type
      when 1
        move_type_random
      when 2
        move_type_toward_player
      when 3
        move_type_custom
      end
    end
  end
end

class Sprite_Character < RPG::Sprite
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        if @character.is_a?(Game_Event)
          @cw = bitmap.width / 4
        else
          @cw = bitmap.width / $game_temp.new_frame_count
        end
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end

class Interpreter
  def upgrade_frames
    $game_temp.new_frame_count = 6
  end

  def downgrade_frames
    $game_temp.new_frame_count = 4
  end
end
If you would like this to apply to events also... then find line "if @character.is_a?(Game_Event)" and remove it, the line below it, the else, and he end.  That should take care of it. 

The system defaults to not using the 6 frame animation, but if you want to change it, just open an event and type in the script section , "upgrade_frames" and if you want to turn it off for some reason.. "downgrade_frames"

Let me know if you have any questions or problems.
 
I get the "if @character.is_a?(Game_Event)" part, "the line below it, the else, and he end" I don't really get what you mean... but in the second part is the script section the comments? What I'm really trying to ask is is there any easier way of putting it? Thanks...
 
this looks interesting, does it just show the steps twice or does it input new frames I.E. can it be used to show halfsteps, like the actors foot is in the air on its way down or something, i dont think this is the case but if it is how does the spacing on that work as far as how you set up your .png files for the characters?
 
This simply resplices the image in 6's, which means that 6 frames of "animation" frames will be displayed. 

So instead of
frame1 frame2 frame3 frame4 for Down, Left, Right, Up it would be
frame1 frame2 frame3 frame4 frame5 frame6 for all 4 dir's
It still divides the existing system by 4 though.. this means that your current ones wont be messed up, it just means that the extra 2 frames of animation will appear blank, because those x,y dont exist on the default character sprites.    As this is the case the default sprites will display as normal... then disappear(for 2 frames, the new ones) then re-appear.  To correct this, simply extend the existing template in width with the additional graphics.

oh and what I meant by the else and the end is
the below lines.. just comment them out as I have in the below code..

Code:
        #if self.is_a?(Game_Event)
        #  @pattern = (@pattern + 1) % 4
        #else
          @pattern = (@pattern + 1) % $game_temp.new_frame_count
        #end

Let me know if you have any other questions.
 

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