Scinaya

Auto Plane (Aero GP's Toolbox)

Apr 28th, 2011
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.78 KB | None | 0 0
  1. #==============================================================================
  2. # ** ExMap_AutoPlane (MACKIE)
  3. #------------------------------------------------------------------------------
  4. #  This script allows you set planes, such as fog and clouds, that are
  5. # automatically displayed onscreen over a map (fog).
  6. #==============================================================================
  7.  
  8. # Map plane table
  9. # Format is [Map ID, Graphic name, Horizontal scrolling, Vertical scrolling,
  10. # Z-coordinate, Opacity (0~255), Blend (0: normal; 1: additive; 2: subtractive)]
  11. # Make sure you place the array elements in the correct order.
  12. # (Example) The graphic "fog.png" will be laid over Map 5. It will scroll 5
  13. #           pixels left and 2 pixels down => [5, "fog", 5, -2, 50, 128, 0]
  14.  
  15. EXMAP_ATPLN_MAPS = [
  16. ]
  17.  
  18. # Graphic Folder
  19. # Specify the folder (Graphic/xxx/) containing image files for this script.
  20. # (0: System; 1: Parallaxes; 2: Pictures; 3: Animations)
  21. EXMAP_ATPLN_FOLDER = 1
  22.  
  23. #------------------------------------------------------------------------------
  24.  
  25. class Game_Map
  26.   alias _exmapln_setup setup unless $@
  27.   alias _exmapln_update update unless $@
  28.   alias _exmapln_set_display_pos set_display_pos unless $@
  29.   alias _exmapln_scroll_down scroll_down unless $@
  30.   alias _exmapln_scroll_left scroll_left unless $@
  31.   alias _exmapln_scroll_right scroll_right unless $@
  32.   alias _exmapln_scroll_up scroll_up unless $@
  33.   #--------------------------------------------------------------------------
  34.   # * Public Instance Variables (Definition added)
  35.   #--------------------------------------------------------------------------
  36.   attr_reader   :fog                      # Fog data
  37.   #--------------------------------------------------------------------------
  38.   # * Setup (Definition added)
  39.   #     map_id : map ID
  40.   #--------------------------------------------------------------------------
  41.   def setup(map_id)
  42.     _exmapln_setup(map_id)
  43.     setup_fog
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # * Setup Fog
  47.   #--------------------------------------------------------------------------
  48.   def setup_fog
  49.     @fog = [0, "", 0, 0, 50, 0, 0]
  50.     @fog_sx = 0
  51.     @fog_sy = 0
  52.     @fog_x = 0
  53.     @fog_y = 0
  54.     for data in EXMAP_ATPLN_MAPS
  55.       if @map_id == data[0]
  56.         @fog = data
  57.         @fog_sx = data[2]
  58.         @fog_sy = data[3]
  59.         break
  60.       end
  61.     end
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * Frame Update (Definition added)
  65.   #--------------------------------------------------------------------------
  66.   def update
  67.     _exmapln_update
  68.     update_fog
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Set Display Position (Definition added)
  72.   #     x : New display X coordinate (*256)
  73.   #     y : New display Y coordinate (*256)
  74.   #--------------------------------------------------------------------------
  75.   def set_display_pos(x, y)
  76.     _exmapln_set_display_pos(x, y)
  77.     @fog_x = x
  78.     @fog_y = y
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * Calculate X coordinate for fog display
  82.   #     bitmap : Fog bitmap
  83.   #--------------------------------------------------------------------------
  84.   def calc_fog_x(bitmap)
  85.     return bitmap == nil ? 0 : @fog_x / 8
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # * Calculate Y coordinate for fog display
  89.   #     bitmap : Fog bitmap
  90.   #--------------------------------------------------------------------------
  91.   def calc_fog_y(bitmap)
  92.     return bitmap == nil ? 0 : @fog_y / 8
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Scroll Down (Definition added)
  96.   #     distance : scroll distance
  97.   #--------------------------------------------------------------------------
  98.   def scroll_down(distance)
  99.     last_y = @display_y
  100.     _exmapln_scroll_down(distance)
  101.     if loop_vertical?
  102.       @fog_y += distance
  103.     else
  104.       @fog_y += @display_y - last_y
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Scroll Left (Definition added)
  109.   #     distance : scroll distance
  110.   #--------------------------------------------------------------------------
  111.   def scroll_left(distance)
  112.     last_x = @display_x
  113.     _exmapln_scroll_left(distance)
  114.     if loop_horizontal?
  115.       @fog_x -= distance
  116.     else
  117.       @fog_x += @display_x - last_x
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # * Scroll Right (Definition added)
  122.   #     distance : scroll distance
  123.   #--------------------------------------------------------------------------
  124.   def scroll_right(distance)
  125.     last_x = @display_x
  126.     _exmapln_scroll_right(distance)
  127.     if loop_horizontal?
  128.       @fog_x += distance
  129.     else
  130.       @fog_x += @display_x - last_x
  131.     end
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Scroll Up (Definition added)
  135.   #     distance : scroll distance
  136.   #--------------------------------------------------------------------------
  137.   def scroll_up(distance)
  138.     last_y = @display_y
  139.     _exmapln_scroll_up(distance)
  140.     if @fog != nil
  141.       if loop_vertical?
  142.         @fog_y -= distance
  143.       else
  144.         @fog_y += @display_y - last_y
  145.       end
  146.     end
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * Update Fog
  150.   #--------------------------------------------------------------------------
  151.   def update_fog
  152.     @fog_x += @fog_sx * 2
  153.     @fog_y += @fog_sy * 2
  154.   end
  155. end
  156.  
  157. class Spriteset_Map
  158.   alias _exmapln_initialize initialize unless $@
  159.   alias _exmapln_dispose dispose unless $@
  160.   alias _exmapln_update update unless $@
  161.   #--------------------------------------------------------------------------
  162.   # * Object Initialization (Definition added)
  163.   #--------------------------------------------------------------------------
  164.   def initialize
  165.     create_fog
  166.     _exmapln_initialize
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * Create Fog
  170.   #--------------------------------------------------------------------------
  171.   def create_fog
  172.     @fog = Plane.new
  173.     if $game_map.fog != nil
  174.       @fog.z = $game_map.fog[4]
  175.       @fog.opacity = $game_map.fog[5]
  176.       @fog.blend_type = $game_map.fog[6]
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # * Dispose (Definition added)
  181.   #--------------------------------------------------------------------------
  182.   def dispose
  183.     _exmapln_dispose
  184.     @fog.dispose
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * Frame Update (Definition added)
  188.   #--------------------------------------------------------------------------
  189.   def update
  190.     _exmapln_update
  191.     update_fog
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # * Update Fog
  195.   #--------------------------------------------------------------------------
  196.   def update_fog
  197.     if @fog_name != $game_map.fog[1]
  198.       @fog_name = $game_map.fog[1]
  199.       if @fog.bitmap != nil
  200.         @fog.bitmap.dispose
  201.         @fog.bitmap = nil
  202.       end
  203.       if @fog_name != ""
  204.         case EXMAP_ATPLN_FOLDER
  205.         when 0
  206.           @fog.bitmap = Cache.system(@fog_name)
  207.         when 1
  208.           @fog.bitmap = Cache.parallax(@fog_name)
  209.         when 2
  210.           @fog.bitmap = Cache.picture(@fog_name)
  211.         when 3
  212.           @fog.bitmap = Cache.animation(@fog_name, 0)
  213.         end
  214.       end
  215.       Graphics.frame_reset
  216.     end
  217.     @fog.ox = $game_map.calc_fog_x(@fog.bitmap)
  218.     @fog.oy = $game_map.calc_fog_y(@fog.bitmap)
  219.   end
  220. end
Advertisement
Add Comment
Please, Sign In to add comment