Michael Super Simple Diagonal Movement Patch

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Michael Super Simple Diagonal Movement Patch

Introduction
This is a simple script to enable diagonal movement by default. It's so simple that it's less than 50 lines, I could bleed to metaphorical dead.


How to Use

Put it under material, above main.

if you're using another movement script, put this above that script.

Script

Code:
#==============================================================================
# Michael Basic 8D
#==============================================================================
class Game_Map
  def x_with_direction(x, d)
   x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0))
  end
  def y_with_direction(y, d)
   y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0))
  end
  def round_x_with_direction(x, d)
   round_x(x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0)))
  end
  def round_y_with_direction(y, d)
   round_y(y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0)))
  end
end
class Game_Character < Game_CharacterBase
  def turn_right_90
   case @direction
     when 1; set_direction(7); when 2; set_direction(4)
     when 3; set_direction(1); when 4; set_direction(8)
     when 6; set_direction(2); when 7; set_direction(9)
     when 8; set_direction(6); when 9; set_direction(3)
   end
  end
  def turn_left_90
   case @direction
     when 1; set_direction(3); when 2; set_direction(6)
     when 3; set_direction(9); when 4; set_direction(2)
     when 6; set_direction(8); when 7; set_direction(1)
     when 8; set_direction(4); when 9; set_direction(7)
   end
  end
end
class Game_Player < Game_Character
  def move_by_input
   return if !movable? || $game_map.interpreter.running?
   case Input.dir8
     when 2,4,6,8; move_straight(Input.dir8)
     when 1; move_diagonal(4, 2); when 3; move_diagonal(6, 2)
     when 7; move_diagonal(4, 8); when 9; move_diagonal(6, 8)
   else; end
  end
end
Terms

Feel free to change, edit, use like as a slave, burn maybe.

Credit is also optional

[10/1/2019] edit: text format is updated to display the script
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
You, sir, are a scholar and a gentleman!

Thank you for this.  It's going to make moving around so much better.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Haha, thanks. There are multiple diagonal script out, the aim of this script is too reduce the amount of process calling and variable checks by making the script static, therefore performance wise is better than most. : p
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
It might be worth putting in your OP that this script disables the mouse (or at least it does if you are using Shaz's Mouse script).  Sadly this means that I shan't be able to use your script after all.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Tested, put it above Shaz script and it should work with the keypad.

Shaz mouse doesn't seem to support diagonal movement.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
It does indeed work with the keypad, thanks.  Yet another reason for me to stick with arrows for my own personal game playing.  
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
diagonal movement method was provided in the default engine, but never used (not sure why, such a great feature), but mouse input method isn't provided, so scripter needs to define them, and defining them requires patient. : x

Anyway, thanks for reporting, I'll update my first post on how to use the script.

Code:
if you're using another movement script, put this above that script.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Although you say credit is optional, I would like to give it, so is it Mike, Michael or something else?
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Mike is my nick since it's easier for my pals to address me, but please go with Michael. Credit page that uses nickname  instead of the real/screen name is kinda funny. : p
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
well, Mike is your screen name... XD
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
I was quite lucky that "Mike" hadn't been taken yet. lol
 

Nightblade50

Developer of "Delta Origins"
Veteran
Joined
Nov 10, 2016
Messages
2,133
Reaction score
4,253
First Language
English, French
Primarily Uses
RMVXA
Script is broken, the forum update messed it up...
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
this should be good.
Code:
#==============================================================================
# Michael Basic 8D
#==============================================================================
class Game_Map
  def x_with_direction(x, d)
    x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0))
  end
  def y_with_direction(y, d)
    y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0))
  end
  def round_x_with_direction(x, d)
    round_x(x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0)))
  end
  def round_y_with_direction(y, d)
    round_y(y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0)))
  end
end
class Game_Character < Game_CharacterBase
  def turn_right_90
    case @direction
      when 1; set_direction(7);
      when 2; set_direction(4)
      when 3; set_direction(1);
      when 4; set_direction(8)
      when 6; set_direction(2);
      when 7; set_direction(9)
      when 8; set_direction(6);
      when 9; set_direction(3)
    end
  end
  def turn_left_90
    case @direction
      when 1; set_direction(3);
      when 2; set_direction(6)
      when 3; set_direction(9);
      when 4; set_direction(2)
      when 6; set_direction(8);
      when 7; set_direction(1)
      when 8; set_direction(4);
      when 9; set_direction(7)
    end
  end
end
class Game_Player < Game_Character
  def move_by_input
    return if !movable? || $game_map.interpreter.running?
    case Input.dir8
      when 2,4,6,8;move_straight(Input.dir8)
      when 1;move_diagonal(4, 2);
      when 3;move_diagonal(6, 2)
      when 7;move_diagonal(4, 8);
      when 9;move_diagonal(6, 8)
    else;
    end
  end
end
 
Last edited:

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