Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Reload this Page [Question] How to add 8-way moving in a game ?

Notices
For all updates, view the main page.

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.



Reply
 
Thread Tools
  #1    
Old March 3rd, 2013 (11:46 AM).
Narzew Narzew is offline
 
Join Date: Jan 2012
Location: Poland
Gender: Male
Nature: Naughty
Posts: 4
Welcome. How to add 8-way moving system in Pokemon Starter Kit (Pokemon Essentials) engine ?
Reply With Quote
  #2    
Old March 3rd, 2013 (01:17 PM).
Riansky's Avatar
Riansky Riansky is offline
Purr
 
Join Date: Jan 2012
Location: Slovenia
Gender: Male
Posts: 199
That would require alot of scripting. Usally you just don't come here, ask a question, and expect someone to do it for you. I recommend you to learn scripting then you should be able to do it
__________________
Reply With Quote
  #3    
Old May 6th, 2013 (03:26 PM).
Narzew Narzew is offline
 
Join Date: Jan 2012
Location: Poland
Gender: Male
Nature: Naughty
Posts: 4
I know how to do in standard RMXP project, but I ask how to do this in PokeStarter.
Reply With Quote
  #4    
Old May 8th, 2013 (04:52 PM).
Pia Carrot's Avatar
Pia Carrot Pia Carrot is offline
Gen II Hacker | PHO Enthusiast
 
Join Date: Aug 2010
Age: 19
Gender: Male
Nature: Adamant
Posts: 559
Cogwheel's 8 Direction Script works with Essentials if modified. My old game Pokemon Mint had 8 Directional movement.
__________________




Coming soon to a forum near you...
Reply With Quote
  #5    
Old May 16th, 2013 (12:28 AM). Edited May 16th, 2013 by thor348.
thor348's Avatar
thor348 thor348 is offline
That's Oak to You
 
Join Date: Nov 2012
Location: Albion
Gender: Male
Nature: Calm
Posts: 136
Here is what I use for 8-direction based movement for events:
#-----------------------------------------------------------------------
class Game_Character
def move_random
case rand(8)
when 0
move_down(false)
when 1
move_lower_left
when 2
move_left(false)
when 3
move_lower_right
when 4
move_right(false)
when 5
move_upper_left
when 6
move_up(false)
when 7
move_upper_right
end
end
#--------------------------------------------------------------------------
def move_toward_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
if not moving? and sy != 0
sx > 0 ? sy > 0 ? move_upper_left : move_lower_left : sy > 0 ? move_upper_right : move_lower_right
return
end
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
else
if not moving? and sx != 0
sx > 0 ? sy > 0 ? move_upper_left : move_lower_left : sy > 0 ? move_upper_right : move_lower_right
return
end
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
#--------------------------------------------------------------------------
def move_away_from_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
if not moving? and sy != 0
sx > 0 ? sy > 0 ? move_lower_left : move_upper_left : sy > 0 ? move_lower_right : move_upper_right
return
end
sx > 0 ? move_right : move_left
if not moving? and sy != 0
sy > 0 ? move_down : move_up
end
else
if not moving? and sy != 0
sx > 0 ? sy > 0 ? move_lower_right : move_upper_right : sy > 0 ? move_lower_left : move_upper_left
return
end
sy > 0 ? move_down : move_up
if not moving? and sx != 0
sx > 0 ? move_right : move_left
end
end
end
end
############################################################
#EDIT-------------------------------------------------------------------------------#
############################################################
http://forum.chaos-project.com/index.php?topic=555.0;wap2

Try this. You will have to tweak it a bit and the section 8a will take a little reading to replace. Also you will have to edit your sprites to work with the 8 directional movement. Hope this helps.
Reply With Quote
  #6    
Old June 29th, 2013 (06:05 PM).
Pia Carrot's Avatar
Pia Carrot Pia Carrot is offline
Gen II Hacker | PHO Enthusiast
 
Join Date: Aug 2010
Age: 19
Gender: Male
Nature: Adamant
Posts: 559
Sorry for bumping an old topic. I have a working 8-way movement script here by Paradog. Credit him if used:

Code:
#==============================================================================
# ++ 8-Direction Characterset Edit ver. 1.01 ++
#  Script by ParaDog
#  http://2d6.parasite.jp/
#------------------------------------------------------------------------------
# Additional 'diagonal' movement is now possible by pushing combinations of the
# vertical and horizontal controls (up & left, etc) simultaneously.
#
# Additional charsets  for the  8-directional movement  are to be stored within
# the "Graphics/Characters" folder, just like the regular charactersets.
#
# Name the new  diagonal movement charactersets  the same  as the regular ones,
# but with a new '_quarter' extension.   As such, you would name the very first
# characterset: 001-Fighter01_quarter.
#------------------------------------------------------------------------------
# Additional notes:
# This system can be used with the 'Dash Characterset Edit' system,  but please
# place this script 'BELOW' the fore-mentioned Dash script for it to work.
#
# As you can combine the two scripts (Dash and 8-Directional), you can also use
# charactersets that show diagonal running action, also stored within the same
# "Graphics/Characters" folder.
#
# Naming the new graphics would require the inclusion of both '_dash' and the 
# '_quarter' extensions as shown here:  001-Fighter01_dash_quarter.
#==============================================================================

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Frame update
  #--------------------------------------------------------------------------
  alias update_para_quarter update
  def update
    update_para_quarter
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # If the direction button is pushed, move the player in that direction
      case Input.dir8
      when 1  # Move Lower Left
        move_lower_left
      when 3  # Move Lower Right
        move_lower_right
      when 7  # Move Upper Left
        move_upper_left
      when 9  # Move Upper Right
        move_upper_right
      end
    end
  end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_para_quarter update
  def update
    update_para_quarter
    if @tile_id == 0
      if (@character.direction - 2) % 2 == 1
        # Checking the presence of the diagonal charset
        if quarter_graphic_exist?(@character)
          # Set the diagonal charset
          if character.dash_on and dash_quarter_graphic_exist?(@character)
            @character_name = @character.character_name + "_dash_quarter"
          else
            @character_name = @character.character_name + "_quarter"
          end
          self.bitmap = RPG::Cache.character(@character_name,
            @character.character_hue)
          # Acquire direction
          case @character.direction
            when 1
              n = 0
            when 3
              n = 2
            when 7
              n = 1
            when 9
              n = 3
          end
        else
          @character.direction = @character.sub_direction
          # When the diagonal charset does not exist, direction
          n = (@character.direction - 2) / 2
        end
        # Set original transfer rectangle
        sx = @character.pattern * @cw
        sy = n * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        # Set original transfer rectangle
        sx = @character.pattern * @cw
        sy = (@character.direction - 2) / 2 * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Diagonal Charset?
  #--------------------------------------------------------------------------
  def quarter_graphic_exist?(character)
    # Reading check
    begin
      RPG::Cache.character(character.character_name.to_s + "_quarter", character.character_hue)
    rescue
      return false
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Dashing Diagonal Charset?
  #--------------------------------------------------------------------------
  def dash_quarter_graphic_exist?(character)
    # Reading check
    begin
      RPG::Cache.character(character.character_name.to_s + "_dash_quarter", character.character_hue)
    rescue
      return false
    end
    return true
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor   :direction        # direction
  attr_accessor   :sub_direction    # sub_direction
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    # If no direction fix
    unless @direction_fix
      @sub_direction = @direction
      @direction = 1
      # Face left if facing right, and face down if facing up
      @sub_direction = (@sub_direction == 6 ? 4 : @sub_direction == 8 ? 2 : @sub_direction)
    end
      return if pbLedge(-1,1)
      return if pbEndSurf(-1,1)
      return if moving?
    # When a down to left or a left to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      # Update coordinates
      @x -= 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right
    # If no direction fix
    unless @direction_fix
      @sub_direction = @direction
      @direction = 3
      # Face right if facing left, and face down if facing up
      @sub_direction = (@sub_direction == 4 ? 6 : @sub_direction == 8 ? 2 : @sub_direction)
    end
      return if pbLedge(1,1)
      return if pbEndSurf(1,1)
      return if moving?
    # When a down to right or a right to down course is passable
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      # Update coordinates
      @x += 1
      @y += 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left
    # If no direction fix
    unless @direction_fix
      @sub_direction = @direction
      @direction = 7
      # Face left if facing right, and face up if facing down
      @sub_direction = (@sub_direction == 6 ? 4 : @sub_direction == 2 ? 8 : @sub_direction)
    end
      return if pbLedge(-1,-1)
      return if pbEndSurf(-1,-1)
      return if moving?
    # When an up to left or a left to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      # Update coordinates
      @x -= 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right
    # If no direction fix
    unless @direction_fix
      @sub_direction = @direction
      @direction = 9
      # Face right if facing left, and face up if facing down
      @sub_direction = (@sub_direction == 4 ? 6 : @sub_direction == 2 ? 8 : @sub_direction)
    end
      return if pbLedge(1,-1)
      return if pbEndSurf(1,-1)
      return if moving?
    # When an up to right or a right to up course is passable
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
       (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      # Update coordinates
      @x += 1
      @y -= 1
      # Increase steps
      increase_steps
    end
  end
  #--------------------------------------------------------------------------
  # * Dash
  #--------------------------------------------------------------------------
  def dash_on
    if @dash_on != nil
      return @dash_on
    else
      return false
    end
  end
end
__________________




Coming soon to a forum near you...
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 09:15 AM.