Beat em up "Walk Style".

● ARCHIVED · READ-ONLY
Started by talic017 6 posts View original ↗
  1. Hi i want to make my "hero and npc" to move in 4 ways direction (up,left,right,down), but only use the (left,right) frames/animation, like in the "beat em up" games.
     
  2. I did this for someone a while ago ... Despain maybe? Let me check ...

    nah, can't find it. Maybe it's been archived.

    I'll have a look when I get home today and see if I still have it.

    Edit: Here you go.

    Code:
    # Only allow player and events to face left or right# If they're set to direction fix, they can change,# otherwise they default back to their last 'valid' direction# If not facing left or right to start with, and# not having direction fix, choose a random directionclass Sprite_Character < Sprite_Base  #--------------------------------------------------------------------------  # * Update Transfer Origin Rectangle  #--------------------------------------------------------------------------  def update_src_rect    # Only face left/right unless on a ladder or direction_fix    if @character.ladder? || @character.direction_fix || [4,6].include?(@character.direction)      @sprite_direction = @character.direction    elsif @old_direction       @sprite_direction = @old_direction    elsif !@sprite_direction      @sprite_direction = [4,6][rand(2)]    end    @old_direction = @sprite_direction if [4,6].include?(@sprite_direction)    if @tile_id == 0      index = @character.character_index      pattern = @character.pattern < 3 ? @character.pattern : 1      sx = (index % 4 * 3 + pattern) * @cw      sy = (index / 4 * 4 + (@sprite_direction - 2) / 2) * @ch      self.src_rect.set(sx, sy, @cw, @ch)    end  endend
    In a new script slot below the others.
  3. Works like a charm, thx.
  4. How can I copy it down?


    # Only allow player and events to face left or right# If they're set to direction fix, they can change,# otherwise they default back to their last 'valid' direction# If not facing left or right to start with, and# not having direction fix, choose a random directionclass Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # * Update Transfer Origin Rectangle #-------------------------------------------------------------------------- def update_src_rect # Only face left/right unless on a ladder or direction_fix if @character.ladder? || @character.direction_fix || [4,6].include?(@character.direction) @sprite_direction = @character.direction elsif @old_direction @sprite_direction = @old_direction elsif !@sprite_direction @sprite_direction = [4,6][rand(2)] end @old_direction = @sprite_direction if [4,6].include?(@sprite_direction) if @tile_id == 0 index = @character.character_index pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw sy = (index / 4 * 4 + (@sprite_direction - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end endend


    It's just one big line.
  5. Hi!


    I'd like to use this Script but as it's only a line, it doesn't work...


    Can somebody help me to adjust it?


    Thanks in advance!
  6. Spoiler
    # Only allow player and events to face left or right
    # If they're set to direction fix, they can change,
    # otherwise they default back to their last 'valid' direction
    # If not facing left or right to start with, and
    # not having direction fix, choose a random direction
    class Sprite_Character < Sprite_Base  
      #--------------------------------------------------------------------------  
      # * Update Transfer Origin Rectangle  
      #--------------------------------------------------------------------------  
      def update_src_rect    
        # Only face left/right unless on a ladder or direction_fix    
        if @character.ladder? || @character.direction_fix || [4,6].include?(@character.direction)      
          @sprite_direction = @character.direction    
        elsif @old_direction       
          @sprite_direction = @old_direction    
        elsif !@sprite_direction      
          @sprite_direction = [4,6][rand(2)]    
        end    
        @old_direction = @sprite_direction if [4,6].include?(@sprite_direction)    
        if @tile_id == 0      
          index = @character.character_index      
          pattern = @character.pattern < 3 ? @character.pattern : 1      
          sx = (index % 4 * 3 + pattern) * @cw      
          sy = (index / 4 * 4 + (@sprite_direction - 2) / 2) * @ch      
          self.src_rect.set(sx, sy, @cw, @ch)    
        end  
      end
    end

    Try that. It should work.