vindaca510

V's Unlimited Parallax Maps v0.1

Sep 23rd, 2013
1,313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.42 KB | None | 0 0
  1. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  2. #                                                                              #
  3. #                          V's Unlimited Parallax Maps                         #
  4. #                                 Version  0.1                                 #
  5. #                                                                              #
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  7. #                                Written By:  V                                #
  8. #                       Last Edited:  September 23, 2013                       #
  9. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  10. #                                                                              #
  11. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  12.  
  13.  
  14. #==============================================================================#
  15. #------------------------------------------------------------------------------#
  16. # ** Disclaimer                                                                #
  17. #------------------------------------------------------------------------------#
  18. #                                                                              #
  19. # This script was intended for Non-commercial use only, if you wish to use     #
  20. # this script in a commercial game please PM me at which ever site you found   #
  21. # this script. Either way please give me credit in your game script as the     #
  22. # writer of this script, and send me a PM about the release of the game/demo.  #
  23. #                                                                              #
  24. #------------------------------------------------------------------------------#
  25. # ** How To Use                                                                #
  26. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  27. #                                                                              #
  28. #  ==========================================================================  #
  29. #  =                                                                        =  #
  30. #  =                                 IMPORTANT                              =  #
  31. #  =                                                                        =  #
  32. #  ==========================================================================  #
  33. #                                                                              #
  34. # * Maps must be imported into the pictures folder.                            #
  35. #                                                                              #
  36. # * Each map MUST HAVE a base layer.                                           #
  37. #                                                                              #
  38. # * You must set the layers opacity that you want visable when you enter the   #
  39. #   map. Base layers opacity is set to 255 by default.                         #
  40. #                                                                              #
  41. # * To veiw a layer above the player set the z_position's value above 101.     #
  42. #                                                                              #
  43. #  ==========================================================================  #
  44. #  * Map Notetags                                                              #
  45. #  ==========================================================================  #
  46. #                                                                              #
  47. #      For Base Layer.                                                         #
  48. #      ~~~~~~~~~~~~~~~                                                         #
  49. #        <Base: name, var_id>                                                  #
  50. #                                                                              #
  51. #      For Additional Layers.                                                  #
  52. #      ~~~~~~~~~~~~~~~~~~~~~~                                                  #
  53. #        <Layer: z_position, name, var_id, opacity_var_id>                     #
  54. #                                                                              #
  55. #  ==========================================================================  #
  56. #  * Map Names                                                                 #
  57. #  ==========================================================================  #
  58. #                                                                              #
  59. # * Maps must be named as such. (image_name + "_" + frame)                     #
  60. #                                                                              #
  61. #    Example of how to name the maps.                                          #
  62. #    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                          #
  63. #    mn1_1                                                                     #
  64. #    woods_1                                                                   #
  65. #    barbershop_1, barbershop_2, barbershop_3, barbershop_4                    #
  66. #                                                                              #
  67. #  ==========================================================================  #
  68. #  * Animating Parallaxes                                                      #
  69. #  ==========================================================================  #
  70. #                                                                              #
  71. # * Map frames are used for animating parallaxes.                              #
  72. # ** To use animations set the layers var to whatever frame you want.          #
  73. # ** To change the opacity set the layers opacity var to what you want.        #
  74. #                                                                              #
  75. #------------------------------------------------------------------------------#
  76. # ** Description                                                               #
  77. #------------------------------------------------------------------------------#
  78. #                                                                              #
  79. #  v0.1                                                                        #
  80. # ~=~=~=~                                                                      #
  81. #                                                                              #
  82. # The script is set up to take a base layer and as many other layers as you    #
  83. # can fit into the maps notebox, as well as animate them.                      #
  84. #                                                                              #
  85. #------------------------------------------------------------------------------#
  86. #==============================================================================#
  87.  
  88.  
  89. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  90. #                                                                              #
  91. #        DO NOT EDIT PASSED THIS POINT UNLESS YOU KNOW WHAT YOUR DOING.        #
  92. #                                                                              #
  93. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. class Game_Map
  134.   def lnote
  135.     t = /<Layer:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)>/i
  136.     n = @map.note
  137.     pm = n.scan(t)
  138.     return pm
  139.   end
  140.   def bnote
  141.     t = /<Base:\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)>/i
  142.     n = @map.note
  143.     pm = n.scan(t)
  144.     return pm
  145.   end
  146.   alias :sp450404210 :setup_parallax
  147.   def setup_parallax
  148.     sp450404210()
  149.   end
  150. end
  151. class Game_System
  152.   attr_accessor :curz
  153.   alias :i040404201 :initialize
  154.   def initialize
  155.     @curz = 0
  156.     i040404201()
  157.   end
  158. end
  159. class Spriteset_Map
  160.   alias :i05042042 :initialize
  161.   def initialize
  162.     @pml = []
  163.     cbl
  164.     i05042042()
  165.     cpm
  166.   end
  167.   def cbl
  168.     bl = $game_map.bnote
  169.     z = -101
  170.     n = bl[0][0]
  171.     v = bl[0][1].to_i
  172.     $game_variables[v] = 0
  173.     var = $game_variables[v]
  174.     name = (n + "_") + var.to_s
  175.     @pmbl = Sprite.new(@viewport1)
  176.     @pmbl.bitmap = Cache.picture(name)
  177.     @pmbl.z = z - $game_system.curz
  178.     @curblvar = var
  179.   end
  180.   def ubl
  181.     bl = $game_map.bnote
  182.     n = bl[0][0]
  183.     v = bl[0][1].to_i
  184.     var = $game_variables[v]
  185.     name = (n + "_") + var.to_s
  186.     if @curblvar != var
  187.       @pmbl.bitmap = Cache.picture(name)
  188.       @curblvar = var
  189.     end
  190.     @pmbl.ox = $game_map.display_x * 32 if @pmbl.ox != $game_map.display_x * 32
  191.     @pmbl.oy = $game_map.display_y * 32 if @pmbl.oy != $game_map.display_y * 32
  192.   end
  193.   def cpm
  194.     @curpmopc = []
  195.     @curpmvars = []
  196.     pm = $game_map.lnote
  197.     if pm != []
  198.       pm.size.times {|i|
  199.         z = pm[i][0]
  200.         n = pm[i][1]
  201.         v = pm[i][2].to_i
  202.         var = $game_variables[v]
  203.         $game_variables[v] = 0
  204.         name = (n + "_") + var.to_s
  205.         o = $game_variables[pm[i][3].to_i]
  206.         @pml[i] = Sprite.new(@viewport1)
  207.         @pml[i].bitmap = Cache.picture(name)
  208.         @pml[i].opacity = o
  209.         @pml[i].z = z.to_i - $game_system.curz
  210.         @curpmvars[i] = var
  211.         @curpmopc[i] = o
  212.       }
  213.     end
  214.   end
  215.   def upm
  216.     cx = []
  217.     cy = []
  218.     pm = $game_map.lnote
  219.     if pm != []
  220.       @pml.size.times {|i|
  221.         n = pm[i][1]
  222.         v = pm[i][2].to_i
  223.         var = $game_variables[v]
  224.         name = (n + "_") + var.to_s
  225.         o = $game_variables[pm[i][3].to_i]
  226.         if @curpmvars[i] != var
  227.           @pml[i].bitmap = Cache.picture(name)
  228.           @curpmvars[i] = var
  229.         end
  230.         if @curpmopc[i] != o
  231.           @pml[i].opacity = o
  232.           @curpmopc[i] = o
  233.         end
  234.       }
  235.       @pml.size.times { |i|
  236.          cx[i] = @pml[i].ox
  237.          cy[i] = @pml[i].oy
  238.          @pml[i].ox = $game_map.display_x * 32 if @pml[i].ox != $game_map.display_x * 32
  239.          @pml[i].oy = $game_map.display_y * 32 if @pml[i].oy != $game_map.display_y * 32
  240.       }
  241.     end
  242.   end
  243.   def dpm
  244.     if @pml != []
  245.       @pml.size.times { |i|
  246.         @pml[i].dispose
  247.         @pml[i].bitmap.dispose
  248.       }
  249.     end
  250.   end
  251.   def dbl
  252.     @pmbl.dispose
  253.     @pmbl.bitmap.dispose
  254.   end
  255.   alias :u420542175045 :update
  256.   def update
  257.     ubl
  258.     upm
  259.     u420542175045()
  260.   end
  261. end
  262. class Scene_Map < Scene_Base
  263.   alias :pt054046404 :post_transfer
  264.   def post_transfer
  265.     @spriteset.dbl
  266.     @spriteset.dpm
  267.     @spriteset.cbl
  268.     @spriteset.cpm
  269.     @spriteset.update
  270.     pt054046404()
  271.   end
  272. end
Advertisement
Add Comment
Please, Sign In to add comment