dsiver144

Turn then Move!

Apr 15th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.85 KB | None | 0 0
  1. #===============================================================================
  2. # Script        : Turn then Move!
  3. # Tác giả       : Dark Sky
  4. # Category      : Character Movement
  5. # Released on   : April 16th 2016
  6. # Description   : Player not only can move but also turn around when press move
  7. #                 buttons.
  8. #===============================================================================
  9. $imported ||= {}
  10. $imported[:dark_move_and_turn] = true
  11. #===============================================================================
  12. module DarkSky
  13.   module MoveAndTurn
  14.     MOVE_DELAY = 10  #Delay - No need to change this!
  15.   end
  16. end
  17. class Game_Player
  18.   include DarkSky::MoveAndTurn
  19.   alias dark_move_and_turn_game_player_initialize initialize
  20.   alias dark_move_and_turn_game_player_move_by_input move_by_input
  21.   #--------------------------------------------------------------------------
  22.   # * Object Initialization
  23.   #--------------------------------------------------------------------------
  24.   def initialize
  25.     dark_move_and_turn_game_player_initialize
  26.     @move_delay = MOVE_DELAY
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Rewrite Move By Input Method.
  30.   #--------------------------------------------------------------------------
  31.   def move_by_input
  32.     return if !movable? || $game_map.interpreter.running?
  33.     if Input.dir4 != 0
  34.       @move_delay -= 1 if @move_delay > 0
  35.     else
  36.       @move_delay = MOVE_DELAY
  37.     end
  38.     if @move_delay > 0
  39.       if Input.press?(:RIGHT)
  40.         set_direction(6)
  41.       end
  42.       if Input.press?(:LEFT)
  43.         set_direction(4)
  44.       end
  45.       if Input.press?(:UP)
  46.         set_direction(8)
  47.       end
  48.       if Input.press?(:DOWN)  
  49.         set_direction(2)
  50.       end
  51.     else
  52.       dark_move_and_turn_game_player_move_by_input
  53.     end
  54.   end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment