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.

Upgrades for f0tz!baerchen's Pixelmovement 1.6

arev

Sponsor

I made two small upgrades to the mentioned script. f0tz didn't like them, so I'm publishing them as a standalone ;)

New features:
- "Resident Evil"-like movement type, that is: left/right turns the player around, up/down moves player forward/backward. It's compatible with 4 and8 directional sprites, and can be changed during the game.
- Map triggers: this is something that lets you paint areas on the map, an then trigger something, when player steps on those areas. The painting takes place on the collision maps. On the white parts you can paint with some other colors, which have to be defined in the Game_Map class. By default 6 new colors are defined (i.e. "red" is Color.new(255,0,0)). After that you can run a parallel event to check if the player steps on any of the colors specified. One event is enough to handle multiple areas with different colors. The checking itself is based on the "Script" function of the "Conditional Branch" command.
- Minor functions used for the RE movement - turn right/left by 45 degrees.

Script:
Code:
#==============================================================================
#==============================================================================
# Upgrades to f0tz!baerchen's Pixelmovement 1.6 by arev
# 10.11.2008
#
# New functions:
# - "Residen Evil"-like movement type:  left/right turns the hero, 
#                                       up moves him forward, 
#                                       down moves him bacward.
#                                       Supports 4/8 directional sprites.
# - Map Triggers: this function lets you to use the areas of the map
#                 to trigger events. To do it just paint the passability map
#                 with some colors. The colors can be defined just below.
#                 To check if a hero is over some color use a script conditional branch:
#                 $game_map.trigger == "red"
#                 where "red" is one of the colors defined.
#==============================================================================
#==============================================================================
# New variable in Pixelmovement_Settings class.
#==============================================================================
class Pixelmovement_Settings
  attr_accessor :re_like
  
  alias ppm_initialize initialize
  
  def initialize
    ppm_initialize
    @re_like = false
  end
  
end
#==============================================================================
# New method for Game_Map class.
#==============================================================================
class Game_Map
  
  def trigger
    
    color = $game_map.collision_map.get_pixel($game_player.x, $game_player.y)
    
    case color
    when Color.new(255,0,0)
      return "red"
    when Color.new(0,255,0)
      return "green"
    when Color.new(0,0,255)
      return "blue"
    when Color.new(255,255,0)
      return "yellow"
    when Color.new(255,0,255)
      return "violet"
    when Color.new(0,255,255)
      return "turquoise"
    when Color.new(255,255,255)
      return "white"
    when Color.new(0,0,0)
      return "black"
    end
    
  end
  
end

#==============================================================================
# New methods for Game_Character class.
#==============================================================================
class Game_Character
  
  #-----------------------------------------------------------------------------
  # turn_right_45, for 8 directions
  #-----------------------------------------------------------------------------
  def turn_right_45(step_by_step = true)    
    case @direction
    when 1
      turn_left(step_by_step)
    when 3
      turn_down(step_by_step)
    when 7
      turn_up(step_by_step)
    when 9
      turn_right(step_by_step)
    when 2
      turn_lower_left(step_by_step)
    when 4
      turn_upper_left(step_by_step)
    when 6
      turn_lower_right(step_by_step)
    when 8
      turn_upper_right(step_by_step)
    end
    
  end
  
  #-----------------------------------------------------------------------------
  # turn_left_45, for 8 directions
  #-----------------------------------------------------------------------------
  def turn_left_45(step_by_step = true)    
    case @direction
    when 1
      turn_down(step_by_step)
    when 3
      turn_right(step_by_step)
    when 7
      turn_left(step_by_step)
    when 9
      turn_up(step_by_step)
    when 2
      turn_lower_right(step_by_step)
    when 4
      turn_lower_left(step_by_step)
    when 6
      turn_upper_right(step_by_step)
    when 8
      turn_upper_left(step_by_step)
    end
    
  end
  
end

#==============================================================================
# Rewrite of Game_Player update method
#==============================================================================
class Game_Player
  
def update     

    #---------------------------------------------------------------------------
    # checks input + moves
    #---------------------------------------------------------------------------
    if not (self.jumping? or $game_system.map_interpreter.running? or 
    @move_to_place or @move_route_forcing or @direction != @old_direction or
    $game_temp.message_window_showing or @ice_sliding)
      steps = [(2 ** (@move_speed - 1)).round, 2].max
      if @last_input
        @x = @real_x / 4
        @y = @real_y / 4
      end
      @last_input = true

      # Sprint fix?
      if @sprint and $pixelmovement.sprint_fix
        move_forward(steps)
        
      # Input
      else
        if $pixelmovement.re_like == true
          if Input.press?(Input::UP)
              move_forward(steps)
          end
          if Input.press?(Input::DOWN)
              move_backward(steps)
          end
          if Input.repeat?(Input::LEFT)
            if $pixelmovement.movement_type == "dir4" or $pixelmovement.movement_type == "dir4diag"
              turn_left_90
            else
              turn_left_45
            end
          end
          if Input.repeat?(Input::RIGHT)
            if $pixelmovement.movement_type == "dir4" or $pixelmovement.movement_type == "dir4diag"
              turn_right_90
            else
              turn_right_45
            end
          end

        else
          return if $pixelmovement.re_like == true
          case Input.send($pixelmovement.movement_type)
          when 1 
            move_lower_left(steps, true, true)
          when 2
            move_down(steps, true, true)
          when 3
            move_lower_right(steps, true, true)
          when 4
            move_left(steps, true, true)
          when 6
            move_right(steps, true, true)
          when 7
            move_upper_left(steps, true, true)
          when 8 
            move_up(steps, true, true)
          when 9 
            move_upper_right(steps, true, true)
          else
            @last_input = false
          end
        end
      end

      #Sprint Script off
      if @sprint
        @move_speed -= $pixelmovement.sprint_speed
        @sprint = false
      end
    end

    @last_real_x = @real_x
    @last_real_y = @real_y
    
    if not moving?
      @move_to_place = false if @move_to_place
      if Input.trigger?(Input::C) and !(@move_route_forcing or @move_to_place)
        self.check_event_trigger_here([0])
        self.check_event_trigger_there([0, 1, 2])
      end
    end

    # checks if sprint is activated
    self.check_sprint_input
    
    # checks if player shall jump
    self.check_jump_input
  
    # checks if player is sliding on ice
    self.check_ice_sliding
    
    super
    
    if not (@move_route_forcing or @move_to_place)
      # Event determinant is via touch of same position event
      result = check_event_trigger_here([1, 2])
      # updates encounter count according to move_speed
      if result == false and (@encounter_count > 0 and 
      not ($DEBUG and Input.press?(Input::CTRL)))
        @encounter_count -= @max_steps
      end
    end
    
    @pattern = @original_pattern if @ice_sliding
                        
    # checks if the player stands on a jump tile
    self.check_jump

    # updates scrolling
    if @real_y > @last_real_y and @real_y - $game_map.display_y > CENTER_Y
      $game_map.scroll_down(@real_y - @last_real_y)
    end
    if @real_x < @last_real_x and @real_x - $game_map.display_x < CENTER_X
      $game_map.scroll_left(@last_real_x - @real_x)
    end
    if @real_x > @last_real_x and @real_x - $game_map.display_x > CENTER_X
      $game_map.scroll_right(@real_x - @last_real_x)
    end
    if @real_y < @last_real_y and @real_y - $game_map.display_y < CENTER_Y
      $game_map.scroll_up(@last_real_y - @real_y)
    end

  end
  
end

#==============================================================================
#==============================================================================
# Change the Resident_Evilness of the movement.
#==============================================================================
#==============================================================================
$pixelmovement.re_like = true

Usage:
To switch the resident evilness of the movement change the:
Code:
$pixelmovement.re_like
at the end of the script (or from event command) to true/false
To check if a player is on some area, let's say it's defined as "red" (Color.new(255,0,0,0)) make a parallel Conditional Branch -> Script:
Code:
$game_map.trigger == "red"
and put anything you like in the condition.

Demo:
http://rapidshare.com/files/162436695/P ... grades.rar
http://www.megaupload.com/?d=26QIB9TR

Credits:
Me for this thingy, f0tz for the bestest script out there ;)
 

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