Guest User

Yanfly Engine Ace - Parallax Lock v1.00

a guest
Jun 8th, 2014
244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Parallax Lock v1.00
  4. # -- Last Updated: 2012.02.19
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-ParallaxLock"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.02.19 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # This script gives developers the ability to lock a map's parallax and cause
  22. # it to not scroll by either vertically, horizontally, or both. Furthermore,
  23. # this script also enables tile locking the map parallax, allowing the parallax
  24. # to only move in conjunction with the player.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Map Notetags - These notetags go in the map notebox in a map's properties.
  34. # -----------------------------------------------------------------------------
  35. # <lock parallax x>
  36. # This prevents the map's parallax from scrolling horizontally.
  37. #
  38. # <lock parallax y>
  39. # This prevents the map's parallax from scrolling vertically.
  40. #
  41. # <full lock parallax>
  42. # This prevents the map's parallax from scrolling at all.
  43. #
  44. # <tile lock parallax>
  45. # This causes the map's parallax to be locked to tiles and scrolls with them.
  46. #
  47. #==============================================================================
  48. # ▼ Compatibility
  49. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  50. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  51. # it will run with RPG Maker VX without adjusting.
  52. #
  53. #==============================================================================
  54. # ▼ Editting anything past this point may potentially result in causing
  55. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  56. # halitosis so edit at your own risk.
  57. #==============================================================================
  58.  
  59. module YEA
  60.   module REGEXP
  61.   module MAP
  62.    
  63.     LOCK_PARALLAX_X = /<(?:LOCK_PARALLAX_X|lock parallax x)>/i
  64.     LOCK_PARALLAX_Y = /<(?:LOCK_PARALLAX_Y|lock parallax y)>/i
  65.     FULL_LOCK_PARALLAX = /<(?:FULL_LOCK_PARALLAX|full lock parallax)>/i
  66.     TILE_LOCK_PARALLAX = /<(?:TILE_LOCK_PARALLAX|tile lock parallax)>/i
  67.    
  68.   end # MAP
  69.   end # REGEXP
  70. end # YEA
  71.  
  72. #==============================================================================
  73. # ■ RPG::Map
  74. #==============================================================================
  75.  
  76. class RPG::Map
  77.  
  78.   #--------------------------------------------------------------------------
  79.   # public instance variables
  80.   #--------------------------------------------------------------------------
  81.   attr_accessor :parallax_lock_x
  82.   attr_accessor :parallax_lock_y
  83.   attr_accessor :parallax_tile_lock
  84.  
  85.   #--------------------------------------------------------------------------
  86.   # common cache: load_notetags_paralock
  87.   #--------------------------------------------------------------------------
  88.   def load_notetags_paralock
  89.     @parallax_lock_x = false
  90.     @parallax_lock_y = false
  91.     @parallax_tile_lock = false
  92.     #---
  93.     self.note.split(/[\r\n]+/).each { |line|
  94.       case line
  95.       #---
  96.       when YEA::REGEXP::MAP::LOCK_PARALLAX_X
  97.         @parallax_lock_x = true
  98.         @parallax_tile_lock = false
  99.       when YEA::REGEXP::MAP::LOCK_PARALLAX_Y
  100.         @parallax_lock_y = true
  101.         @parallax_tile_lock = false
  102.       when YEA::REGEXP::MAP::FULL_LOCK_PARALLAX
  103.         @parallax_lock_x = true
  104.         @parallax_lock_y = true
  105.         @parallax_tile_lock = false
  106.       when YEA::REGEXP::MAP::TILE_LOCK_PARALLAX
  107.         @parallax_lock_x = false
  108.         @parallax_lock_y = false
  109.         @parallax_tile_lock = true
  110.       #---
  111.       end
  112.     } # self.note.split
  113.     #---
  114.   end
  115.  
  116. end # RPG::Map
  117.  
  118. #==============================================================================
  119. # ■ Game_Map
  120. #==============================================================================
  121.  
  122. class Game_Map
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # alias method: setup
  126.   #--------------------------------------------------------------------------
  127.   alias game_map_setup_parallax_paralock setup_parallax
  128.   def setup_parallax
  129.     @map.load_notetags_paralock
  130.     game_map_setup_parallax_paralock
  131.   end
  132.  
  133.   #--------------------------------------------------------------------------
  134.   # new method: parallax_lock_x?
  135.   #--------------------------------------------------------------------------
  136.   def parallax_lock_x?
  137.     return @map.parallax_lock_x
  138.   end
  139.  
  140.   #--------------------------------------------------------------------------
  141.   # new method: parallax_lock_y?
  142.   #--------------------------------------------------------------------------
  143.   def parallax_lock_y?
  144.     return @map.parallax_lock_y
  145.   end
  146.  
  147.   #--------------------------------------------------------------------------
  148.   # new method: parallax_tile_lock?
  149.   #--------------------------------------------------------------------------
  150.   def parallax_tile_lock?
  151.     return @map.parallax_tile_lock
  152.   end
  153.  
  154.   #--------------------------------------------------------------------------
  155.   # alias method: parallax_ox
  156.   #--------------------------------------------------------------------------
  157.   alias game_map_parallax_ox_paralock parallax_ox
  158.   def parallax_ox(bitmap)
  159.     return 0 if parallax_lock_x?
  160.     return @display_x * 32 if parallax_tile_lock?
  161.     return game_map_parallax_ox_paralock(bitmap)
  162.   end
  163.  
  164.   #--------------------------------------------------------------------------
  165.   # alias method: parallax_oy
  166.   #--------------------------------------------------------------------------
  167.   alias game_map_parallax_oy_paralock parallax_oy
  168.   def parallax_oy(bitmap)
  169.     return 0 if parallax_lock_y?
  170.     return @display_y * 32 if parallax_tile_lock?
  171.     return game_map_parallax_oy_paralock(bitmap)
  172.   end
  173.  
  174. end # Game_Map
  175.  
  176. #==============================================================================
  177. #
  178. # ▼ End of File
  179. #
  180. #==============================================================================
RAW Paste Data