Advertisement
DrDhoom

[RGSS2] Player Turn & Move

May 6th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.83 KB | None | 0 0
  1. =begin
  2. #===============================================================================
  3.   Player Turn & Move (VX)
  4.   Author : SirBilly (silentkingdom.com)
  5.   Version : 1.0
  6.   Date : 9 June 2013
  7. --------------------------------------------------------------------------------
  8.   This Script makes your character turn and face the direction to move before
  9.   moving in the chosen direction just like in the pokemon games.
  10.  
  11.   *Overwrites move_by_input method in Game_Player class.
  12. #===============================================================================
  13.  Instructions
  14. --------------------------------------------------------------------------------
  15.   To install this script, open up your script editor and copy/paste this script
  16.   to an open slot below Materials but above Main.
  17. #===============================================================================
  18.  Terms of Use
  19. --------------------------------------------------------------------------------
  20.  * Free to use for both commercial and non-commercial projects.
  21.  * Do not claim this as your own.
  22.  * Crediting me in the game's credits would be appreciated.
  23. #===============================================================================
  24. =end
  25. #===============================================================================
  26. # * Script Configuration *
  27. #===============================================================================
  28. module SK
  29.   module TURNANDMOVE
  30.  #------------------------------------------------------------------------------
  31.  # This is the delay time between the directional keys imput default is 7.
  32.  #------------------------------------------------------------------------------
  33.   Delay_Time = 7
  34.  #------------------------------------------------------------------------------
  35.  # Note: works best when kept over 5 and under 10.
  36.  #------------------------------------------------------------------------------
  37.   end
  38.  end
  39. #===============================================================================
  40. # * End of Configuration *
  41. #===============================================================================
  42. class Game_Player < Game_Character
  43. #-------------------------------------------------------------------------------
  44. # Frame Update For Wait Time
  45. #-------------------------------------------------------------------------------
  46.  alias sirbilly_turn_and_move_update update
  47.   def update
  48.     sirbilly_turn_and_move_update
  49.     @wait_time = SK::TURNANDMOVE::Delay_Time  unless @wait_time != nil
  50.     @wait_time -= 1 unless @wait_time == 0
  51.   end
  52. #-------------------------------------------------------------------------------
  53. # Movement via Input from Directional Buttons
  54. #-------------------------------------------------------------------------------
  55.   def move_by_input
  56.     return if !movable? || $game_map.interpreter.running?
  57.       case Input.dir4
  58.       when 2; if Input.trigger?(Input::DOWN)
  59.          @wait_time = SK::TURNANDMOVE::Delay_Time
  60.          set_direction(2)
  61.        elsif @wait_time == 0
  62.          move_down
  63.         end
  64.       when 4; if Input.trigger?(Input::LEFT)
  65.          @wait_time = SK::TURNANDMOVE::Delay_Time
  66.          set_direction(4)
  67.        elsif @wait_time == 0
  68.          move_left
  69.         end
  70.       when 6; if Input.trigger?(Input::RIGHT)
  71.          @wait_time = SK::TURNANDMOVE::Delay_Time
  72.          set_direction(6)
  73.        elsif @wait_time == 0
  74.          move_right
  75.         end
  76.       when 8; if Input.trigger?(Input::UP)
  77.          @wait_time = SK::TURNANDMOVE::Delay_Time
  78.          set_direction(8)
  79.        elsif @wait_time == 0
  80.          move_up
  81.         end
  82.       end
  83.    end
  84.  end
  85. #==============================================================================#
  86. #                      http://silentkingdom.com/                               #
  87. #==============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement