Diagonal movement going above tiles

Benja

Lead Developer
Veteran
Joined
Mar 5, 2014
Messages
131
Reaction score
25
First Language
English
Primarily Uses
RMVXA
I have taken up a diagonal moving script 

#==============================================================================
# 8 Dir Move                                                  JV Master Script
#------------------------------------------------------------------------------
# Make player move in 8 dir, supports diagonal pattern.
#==============================================================================


module JvScripts
  module Dirs8
    
    Switch = 0               # Switch id for toggle 4/8 dir, 0 if always 8 dir
    DiagonalSuffix = "_di"   # Suffix for 8 dir charsets
                             # 8 dir charsets include in the first char
                             # the orthogonal and in the second the diagonal
  end
end


#==============================================================================
# Game CharacterBase
#==============================================================================
class Game_CharacterBase
  
  def move_diagonal(horz, vert)
    @move_succeed = diagonal_passable?(x, y, horz, vert)
    if @move_succeed
      @x = $game_map.round_x_with_direction(@x, horz)
      @y = $game_map.round_y_with_direction(@y, vert)
      @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
      @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
      increase_steps
    end
    if diagonal_charset?
      set_direction_diagonal(horz, vert)
    else
      set_direction(horz) if @direction == reverse_dir(horz)
      set_direction(vert) if @direction == reverse_dir(vert)
    end
  end
  
  def set_direction(d)
    if !@direction_fix && d != 0
      @direction = d
      @character_index = 0 if diagonal_charset?
    end
    @stop_count = 0
  end
  
  def set_direction_diagonal(horz, vert)
    if !@direction_fix && horz != 0 && vert != 0
      if horz == 4 && vert == 2
        @direction = 2
      elsif horz == 4 && vert == 8
        @direction = 4
      elsif horz == 6 && vert == 2
        @direction = 6
      elsif horz == 6 && vert == 8
        @direction = 8
      end
      
      @character_index = 1
    end
    @stop_count = 0
  end
  
  def diagonal_charset?
    true if @character_name.include?(JvScripts::Dirs8::DiagonalSuffix)
  end
end


#==============================================================================
# Game Player
#==============================================================================
class Game_Player < Game_Character
  def move_by_input
    return if !movable? || $game_map.interpreter.running?
    if JvScripts::Dirs8::Switch > 0
      if $game_switches[JvScripts::Dirs8::Switch] == true
        case Input.dir8
        when 2, 4, 6, 8
          move_straight(Input.dir4)
        when 1
          move_diagonal(4, 2)
        when 3
          move_diagonal(6, 2)
        when 7
          move_diagonal(4, 8)
        when 9
          move_diagonal(6, 8)
        end
      else
        move_straight(Input.dir4) if Input.dir4 > 0
      end
    else
      if Input.dir8 > 0
        case Input.dir8
        when 2, 4, 6, 8
          move_straight(Input.dir4)
        when 1
          move_diagonal(4, 2)
        when 3
          move_diagonal(6, 2)
        when 7
          move_diagonal(4, 8)
        when 9
          move_diagonal(6, 8)
        end
      end
    end
  end
end
#==============================================================================



And it works perfectly, except one thing. this: http://i.imgur.com/MFRB1cR.png


If players move diagonally down when next to an impassable tile, their sprite with appear to slightly go over it. It doesn't affect gameplay at all, but I'd really rather have it fixed, as it is rather unattractive. If anyone could tell me how to fix the script, or just make impassable tiles above players, I'd appreciate it.


But I am trying to avoid parallax mapping as much as humanly possible, or picture mapping, or any of the sort. Thanks in advance.
 

Benja

Lead Developer
Veteran
Joined
Mar 5, 2014
Messages
131
Reaction score
25
First Language
English
Primarily Uses
RMVXA

JamesVoss

Villager
Member
Joined
Jul 26, 2016
Messages
25
Reaction score
7
First Language
English
Primarily Uses
So don't quote me on this but I believe simply changing the possibility of the tiles to the star will make it appear above but it will also allow the player to walk behind them, However using a blank event on Same as Characters over any tiles you can access from the main path would block the player. You might alternatively want to place a copy of all the corner auto tiles into B or C or D or E and place an event with those graphics on top of all the corner with it set to above characters.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top