Advertisement
LiTTleDRAgo

[RGSS/2/3] Drago - Diagonal Scroll

Aug 2nd, 2013
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.36 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # DRG - Diagonal Scroll
  3. # Version: 1.01
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #
  7. # How to Use :
  8. #
  9. #  Script : scroll_map(type, distance, speed)
  10. #       type  : direction (1,2,3,4,5,6,7,8,9)
  11. #       dist  : distance scrolling
  12. #       speed : (1:slowest 2:slower 3:slow 4:fast 5: faster 6:fastest)
  13. #  
  14. #==============================================================================
  15. ($imported ||= {})[:drg_diagonal_scroll] = 1.01
  16. #==============================================================================
  17. # ** Interpreter
  18. #------------------------------------------------------------------------------
  19. #  This interpreter runs event commands. This class is used within the
  20. #  Game_System class and the Game_Event class.
  21. #==============================================================================
  22. Klass = defined?(Window_ActorCommand) ? Game_Interpreter : Interpreter
  23. class Klass
  24.   #--------------------------------------------------------------------------
  25.   # scroll_map
  26.   #       type  : (1,2,3,4,5,6,7,8,9)
  27.   #       dist  : distance scrolling
  28.   #       speed : (1:slowest 2:slower 3:slow 4:fast 5: faster 6:fastest)
  29.   #--------------------------------------------------------------------------
  30.   def scroll_map(type, dist, speed)
  31.     return true if $game_temp.instance_variable_get(:@in_battle)
  32.     return true if $game_party.instance_variable_get(:@in_battle)
  33.     return false if $game_map.scrolling?
  34.     speed += 0.5 if type == 1 or type == 3 or type ==7 or type == 9
  35.     $game_map.start_scroll(type, dist, speed)
  36.     return true
  37.   end
  38. end
  39.  
  40. #==============================================================================
  41. # ** Game_Map
  42. #------------------------------------------------------------------------------
  43. #  This class handles the map. It includes scrolling and passable determining
  44. #  functions. Refer to "$game_map" for the instance of this class.
  45. #==============================================================================
  46.  
  47. class Game_Map
  48.   #--------------------------------------------------------------------------
  49.   # * Alias Method
  50.   #--------------------------------------------------------------------------
  51.   @@scroll = method_defined?(:do_scroll) ?  :do_scroll : :update
  52.   alias_method :update_scrolling_straight, :"#{@@scroll}"
  53.   #--------------------------------------------------------------------------
  54.   # * Frame Update
  55.   #--------------------------------------------------------------------------
  56.   define_method(:"#{@@scroll}") do |*args|
  57.     update_scrolling_diagonal
  58.     update_scrolling_straight(*args)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Update Scrolling Diagonal
  62.   #--------------------------------------------------------------------------
  63.   def update_scrolling_diagonal
  64.     if scrolling?
  65.       distance = 2 ** @scroll_speed
  66.       distance = scroll_distance if defined?(scroll_distance)
  67.       case @scroll_direction
  68.       when 1 then [scroll_down(distance), scroll_left(distance) ]
  69.       when 3 then [scroll_down(distance), scroll_right(distance)]
  70.       when 7 then [scroll_up(distance),   scroll_left(distance) ]
  71.       when 9 then [scroll_up(distance),   scroll_right(distance)]
  72.       end
  73.     end
  74.   end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement