Advertisement
LiTTleDRAgo

[RGSS] Multiple Fog

Oct 21st, 2011
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.94 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # [Xp] Multiple Fog
  3. # Version: 2.31
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6.  
  7. if true
  8. #==============================================================================
  9. # ** Spriteset_Map
  10. #------------------------------------------------------------------------------
  11. #  This class brings together map screen sprites, tilemaps, etc.
  12. #  It's used within the Scene_Map class.
  13. #==============================================================================
  14.  
  15. Cache = RPG::Cache if !defined? Cache
  16. class Spriteset_Map
  17.   #--------------------------------------------------------------------------
  18.   # * Alias Listing
  19.   #--------------------------------------------------------------------------
  20.   alias dispose_multifog dispose
  21.   alias update_multifog update
  22.   #--------------------------------------------------------------------------
  23.   # * Object Initialization
  24.   #--------------------------------------------------------------------------
  25.   def multifog_setup(v=@viewport1)
  26.     @fog2, @fog3, @fog4 = Plane.new(v), Plane.new(v), Plane.new(v)
  27.  
  28.     @fog2.z = -400
  29.     @fog3.z = -300  
  30.     @fog4.z = -200  
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Dispose
  34.   #--------------------------------------------------------------------------
  35.   def dispose
  36.     dispose_multifog
  37.     [@fog2, @fog3, @fog4].each {|i| i.dispose}
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # * Frame Update
  41.   #--------------------------------------------------------------------------
  42.   def update
  43.     multifog_setup if @fog2.nil? or @fog3.nil? or @fog4.nil?
  44.     all_fog_update
  45.     update_multifog
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # * All Fog Update
  49.   #--------------------------------------------------------------------------
  50.   def all_fog_update
  51.     #---------------------------------------------------------------------------
  52.     # FOG 2
  53.     #---------------------------------------------------------------------------
  54.     if $game_system.fog2_name
  55.       if @fog2_name != $game_system.fog2_name
  56.         @fog2_name = $game_system.fog2_name
  57.         if @fog2.bitmap != nil
  58.           @fog2.bitmap.dispose
  59.           @fog2.bitmap = nil
  60.         end
  61.         if @fog2_name != ''
  62.           @fog2.bitmap = Cache.fog(@fog2_name,0) rescue Cache.panorama(@fog2_name,0)
  63.         end
  64.         Graphics.frame_reset
  65.       end    
  66.       @fog2.opacity = $game_system.fog2_opacity
  67.       @fog2.blend_type = $game_system.fog2_blend_type
  68.       @fog2.zoom_x = $game_system.fog2_zoom
  69.       @fog2.zoom_y = $game_system.fog2_zoom
  70.       @fog2_ox.nil? ? @fog2_ox = 0 :  @fog2_ox += $game_system.fog2_ox
  71.       @fog2_oy.nil? ? @fog2_oy = 0 :  @fog2_oy += $game_system.fog2_oy
  72.       @fog2.ox = $game_map.display_x / 3 + ($game_player.screen_x / 3 ) + @fog2_ox
  73.       @fog2.oy = $game_map.display_y / 3 +  @fog2_oy
  74.     end
  75.     #---------------------------------------------------------------------------
  76.     # FOG 3
  77.     #---------------------------------------------------------------------------    
  78.     if $game_system.fog3_name    
  79.       if @fog3_name != $game_system.fog3_name
  80.         @fog3_name = $game_system.fog3_name
  81.         if @fog3.bitmap != nil
  82.           @fog3.bitmap.dispose
  83.           @fog3.bitmap = nil
  84.         end
  85.         if @fog3_name != ''
  86.           @fog3.bitmap = Cache.fog(@fog3_name,0) rescue Cache.panorama(@fog3_name,0)
  87.         end
  88.         Graphics.frame_reset
  89.       end  
  90.       @fog3.opacity = $game_system.fog3_opacity    
  91.       @fog3.blend_type = $game_system.fog3_blend_type
  92.       @fog3.zoom_x = $game_system.fog3_zoom
  93.       @fog3.zoom_y = $game_system.fog3_zoom
  94.       @fog3_ox.nil? ? @fog3_ox = 0 :  @fog3_ox += $game_system.fog3_ox
  95.       @fog3_oy.nil? ? @fog3_oy = 0 :  @fog3_oy += $game_system.fog3_oy
  96.       @fog3.ox = $game_map.display_x / 3 + ($game_player.screen_x / 2 ) + @fog3_ox
  97.       @fog3.oy = $game_map.display_y / 4 + @fog3_oy  
  98.     end
  99.     #---------------------------------------------------------------------------
  100.     # FOG 4
  101.     #---------------------------------------------------------------------------
  102.     if $game_system.fog4_name
  103.       if @fog4_name != $game_system.fog4_name
  104.         @fog4_name = $game_system.fog4_name
  105.         if @fog4.bitmap != nil
  106.           @fog4.bitmap.dispose
  107.           @fog4.bitmap = nil
  108.         end
  109.         if @fog4_name != ''
  110.           @fog4.bitmap = Cache.fog(@fog4_name,0) rescue Cache.panorama(@fog4_name,0)
  111.         end
  112.         Graphics.frame_reset
  113.       end  
  114.       @fog4.opacity = $game_system.fog4_opacity    
  115.       @fog4.blend_type = $game_system.fog4_blend_type
  116.       @fog4.zoom_x = $game_system.fog4_zoom
  117.       @fog4.zoom_y = $game_system.fog4_zoom
  118.       @fog4_ox.nil? ? @fog4_ox = 0 :  @fog4_ox += $game_system.fog4_ox
  119.       @fog4_oy.nil? ? @fog4_oy = 0 :  @fog4_oy += $game_system.fog4_oy
  120.       @fog4.ox = $game_map.display_x / 3 + ($game_player.screen_x / 2 ) + @fog4_ox
  121.       @fog4.oy = $game_map.display_y / 4 + @fog4_oy  
  122.     end
  123.     #---------------------------------------------------------------------------
  124.   end
  125. end
  126.  
  127. class Interpreter
  128.  
  129.   def set_fog2(n = '',ox = 0,oy = 0,opacity = 255,blend=0,zoom = 1.00)
  130.     $game_system.fog2_name = n
  131.     $game_system.fog2_ox = ox
  132.     $game_system.fog2_oy = oy    
  133.     $game_system.fog2_opacity = opacity
  134.     $game_system.fog2_blend_type = blend
  135.     $game_system.fog2_zoom = zoom
  136.   end
  137.    
  138.   def set_fog3(n = '',ox = 0,oy = 0,opacity = 255,blend=0,zoom = 1.00)
  139.     $game_system.fog3_name = n
  140.     $game_system.fog3_ox = ox
  141.     $game_system.fog3_oy = oy      
  142.     $game_system.fog3_opacity = opacity
  143.     $game_system.fog3_blend_type = blend
  144.     $game_system.fog3_zoom = zoom
  145.   end
  146.    
  147.   def set_fog4(n = '',ox = 0,oy = 0,opacity = 255,blend=0,zoom = 1.00)
  148.     $game_system.fog4_name = n
  149.     $game_system.fog4_ox = ox
  150.     $game_system.fog4_oy = oy
  151.     $game_system.fog4_opacity = opacity
  152.     $game_system.fog4_blend_type = blend
  153.     $game_system.fog4_zoom = zoom
  154.   end
  155.  
  156.   def reset_fog
  157.     set_fog2('', 0, 0)
  158.     set_fog3('', 0, 0)
  159.     set_fog4('', 0, 0)
  160.   end
  161. end
  162. #===============================================================================
  163. # ■ GAME_SYSTEM
  164. #===============================================================================
  165. class Game_System
  166.   attr_accessor :fog2_name, :fog2_zoom, :fog2_opacity, :fog2_blend_type,
  167.       :fog2_ox, :fog2_oy,
  168.  
  169.       :fog3_name, :fog3_zoom, :fog3_opacity, :fog3_blend_type,
  170.       :fog3_ox, :fog3_oy,    
  171.  
  172.       :fog4_name, :fog4_zoom, :fog4_opacity, :fog4_blend_type,
  173.       :fog4_ox, :fog4_oy
  174. end  
  175.    
  176.  
  177. $drago_multifog = true
  178. end
  179. #--------------------------------------------------------------------------
  180. # END OF SCRIPT
  181. #--------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement