Advertisement
diamondandplatinum3

Battle Parallax Background ~ RGSS2

Sep 7th, 2012
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.30 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Battle Parallax Background
  3. #             Version: 1.0
  4. #             Author: DiamondandPlatinum3
  5. #             Date: September 6, 2012
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script allows you to use a parallax as a background for your
  10. #    Battles. It also allows you to scroll the parallax like any regular
  11. #    map parallax.
  12. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. #------------------------------------------------------------------------------
  14. #  Instructions:
  15. #    
  16. #     ~  The method to alter the battle parallax is to use a script call with
  17. #        the following line of code
  18. #
  19. #         setbattleparallax( filename, scrollx, scrolly )
  20. #
  21. #        Where 'filename' is where you enter the name of the parallax, this must
  22. #        be done in quotation marks ( " " ).
  23. #        'scrollx' is the amount the parallax will scroll to the left or right.
  24. #        'scrolly' is the amount the parallax will scroll up or down.
  25. #
  26. #
  27. #     -  If you do not want to change a specific value, simply pass in nil as the
  28. #        parameter
  29. #
  30. #
  31. #     -  You can find screenshots to visually explain the method
  32. #        Here: http://img4host.net/upload/07161945504a02819c6ec.png
  33. #
  34. #
  35. #     -  You can also use negative numbers to reverse the directions of the
  36. #        parallax scroll. You'll need to play around with it to achieve the
  37. #        desired effect
  38. #
  39. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  40. #
  41. #
  42. #                  THERE IS NO EDITABLE REGION TO THIS SCRIPT
  43. #
  44. #==============================================================================
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. #==============================================================================
  56. # ** Spriteset_Battle
  57. #------------------------------------------------------------------------------
  58. #  This class brings together battle screen sprites. It's used within the
  59. # Scene_Battle class.
  60. #==============================================================================
  61.  
  62. class Spriteset_Battle
  63.   #--------------------------------------------------------------------------
  64.   # * Overwritten Functions
  65.   #--------------------------------------------------------------------------
  66.   #     create_battleback
  67.   #     update_battleback
  68.   #     dispose_battleback_bitmap
  69.   #     dispose_battleback
  70.   #
  71.   #--------------------------------------------------------------------------
  72.   # * Alias Listings
  73.   #--------------------------------------------------------------------------
  74.   alias dp3_batlparallax_sprsetbatl_init_1h2g       initialize
  75.   alias dp3_batlparallax_sprsetbatl_dispose_1h2g    dispose
  76.   alias dp3_batlparallax_sprsetbatl_update_1h2g     update
  77.   #--------------------------------------------------------------------------
  78.   # * Object Initialization
  79.   #--------------------------------------------------------------------------
  80.   def initialize
  81.     # Call Original Method
  82.     dp3_batlparallax_sprsetbatl_init_1h2g
  83.    
  84.     create_parallax
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Frame Update
  88.   #--------------------------------------------------------------------------
  89.   def update
  90.     update_parallax
  91.    
  92.     # Call Original Method
  93.     dp3_batlparallax_sprsetbatl_update_1h2g
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Free
  97.   #--------------------------------------------------------------------------
  98.   def dispose
  99.     dispose_parallax
  100.    
  101.     # Call Original Method
  102.     dp3_batlparallax_sprsetbatl_dispose_1h2g
  103.   end
  104.  
  105.  
  106.  
  107.   #--------------------------------------------------------------------------
  108.   # * Create Battle Background (Floor) Sprite
  109.   #--------------------------------------------------------------------------
  110.   def create_battleback
  111.     @battleback_sprite = nil
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # * Create Parallax
  115.   #--------------------------------------------------------------------------
  116.   def create_parallax
  117.     @backparallax = Plane.new(@viewport1)
  118.     @backparallax.bitmap = Cache.parallax($game_system.battleparallaxgraphicname)
  119.     @backparallax.z = 0
  120.   end
  121.  
  122.  
  123.  
  124.  
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # * Update Battle Background (Floor) Sprite
  128.   #--------------------------------------------------------------------------
  129.   def update_battleback
  130.     @battleback_sprite.update if @battleback_sprite
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Update Parallax
  134.   #--------------------------------------------------------------------------
  135.   def update_parallax
  136.     if @backparallax
  137.       @backparallax.ox += $game_system.battleparallaxgraphicscrollx
  138.       @backparallax.oy += $game_system.battleparallaxgraphicscrolly
  139.     end
  140.   end
  141.  
  142.  
  143.  
  144.  
  145.   #--------------------------------------------------------------------------
  146.   # * Dispose of Battleback Bitmap
  147.   #--------------------------------------------------------------------------
  148.   def dispose_battleback_bitmap
  149.     @battleback_sprite.bitmap.dispose if @battleback_sprite
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Dispose of Battleback Sprite
  153.   #--------------------------------------------------------------------------
  154.   def dispose_battleback
  155.     @battleback_sprite.dispose if @battleback_sprite
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # * Free Battle Parallax
  159.   #--------------------------------------------------------------------------
  160.   def dispose_parallax
  161.     @backparallax.dispose if @backparallax
  162.   end
  163.  
  164. end # of Class
  165.  
  166.  
  167.  
  168.  
  169. #==============================================================================
  170. # ** Game_System
  171. #------------------------------------------------------------------------------
  172. #  This class handles system data. It saves the disable state of saving and
  173. # menus. Instances of this class are referenced by $game_system.
  174. #==============================================================================
  175.  
  176. class Game_System
  177.   #--------------------------------------------------------------------------
  178.   # * New Public Instance Variables
  179.   #--------------------------------------------------------------------------
  180.   attr_accessor :battleparallaxgraphicname
  181.   attr_accessor :battleparallaxgraphicscrollx
  182.   attr_accessor :battleparallaxgraphicscrolly
  183.   #--------------------------------------------------------------------------
  184.   # * Alias Listings
  185.   #--------------------------------------------------------------------------
  186.   alias dp3_batlparallax_gamesys_init_1h2g     initialize
  187.   #--------------------------------------------------------------------------
  188.   # * Object Initialization
  189.   #--------------------------------------------------------------------------
  190.   def initialize
  191.    
  192.     # Call Original Method
  193.     dp3_batlparallax_gamesys_init_1h2g
  194.    
  195.     # Setup Parallax (safety precautions in case the user doesn't do it themselves)
  196.     @battleparallaxgraphicname    = "BlueSky"
  197.     @battleparallaxgraphicscrollx = 0
  198.     @battleparallaxgraphicscrolly = 0
  199.   end
  200.  
  201. end # of Class
  202.  
  203.  
  204.  
  205.  
  206.  
  207. #==============================================================================
  208. # ** Game_Interpreter
  209. #------------------------------------------------------------------------------
  210. #  An interpreter for executing event commands. This class is used within the
  211. # Game_Map, Game_Troop, and Game_Event classes.
  212. #==============================================================================
  213.  
  214. class Game_Interpreter  
  215.   #--------------------------------------------------------------------------
  216.   # * Set Battle Parallax
  217.   #--------------------------------------------------------------------------
  218.   def setbattleparallax( filename, scrollx, scrolly )
  219.     $game_system.battleparallaxgraphicname    = filename if filename.is_a?(String)
  220.     $game_system.battleparallaxgraphicscrollx = scrollx  if scrollx.is_a?(Integer)
  221.     $game_system.battleparallaxgraphicscrolly = scrolly  if scrolly.is_a?(Integer)
  222.   end
  223.  
  224. end # of Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement