Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** ExMap_AutoPlane (MACKIE)
- #------------------------------------------------------------------------------
- # This script allows you set planes, such as fog and clouds, that are
- # automatically displayed onscreen over a map (fog).
- #==============================================================================
- # Map plane table
- # Format is [Map ID, Graphic name, Horizontal scrolling, Vertical scrolling,
- # Z-coordinate, Opacity (0~255), Blend (0: normal; 1: additive; 2: subtractive)]
- # Make sure you place the array elements in the correct order.
- # (Example) The graphic "fog.png" will be laid over Map 5. It will scroll 5
- # pixels left and 2 pixels down => [5, "fog", 5, -2, 50, 128, 0]
- EXMAP_ATPLN_MAPS = [
- ]
- # Graphic Folder
- # Specify the folder (Graphic/xxx/) containing image files for this script.
- # (0: System; 1: Parallaxes; 2: Pictures; 3: Animations)
- EXMAP_ATPLN_FOLDER = 1
- #------------------------------------------------------------------------------
- class Game_Map
- alias _exmapln_setup setup unless $@
- alias _exmapln_update update unless $@
- alias _exmapln_set_display_pos set_display_pos unless $@
- alias _exmapln_scroll_down scroll_down unless $@
- alias _exmapln_scroll_left scroll_left unless $@
- alias _exmapln_scroll_right scroll_right unless $@
- alias _exmapln_scroll_up scroll_up unless $@
- #--------------------------------------------------------------------------
- # * Public Instance Variables (Definition added)
- #--------------------------------------------------------------------------
- attr_reader :fog # Fog data
- #--------------------------------------------------------------------------
- # * Setup (Definition added)
- # map_id : map ID
- #--------------------------------------------------------------------------
- def setup(map_id)
- _exmapln_setup(map_id)
- setup_fog
- end
- #--------------------------------------------------------------------------
- # * Setup Fog
- #--------------------------------------------------------------------------
- def setup_fog
- @fog = [0, "", 0, 0, 50, 0, 0]
- @fog_sx = 0
- @fog_sy = 0
- @fog_x = 0
- @fog_y = 0
- for data in EXMAP_ATPLN_MAPS
- if @map_id == data[0]
- @fog = data
- @fog_sx = data[2]
- @fog_sy = data[3]
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Definition added)
- #--------------------------------------------------------------------------
- def update
- _exmapln_update
- update_fog
- end
- #--------------------------------------------------------------------------
- # * Set Display Position (Definition added)
- # x : New display X coordinate (*256)
- # y : New display Y coordinate (*256)
- #--------------------------------------------------------------------------
- def set_display_pos(x, y)
- _exmapln_set_display_pos(x, y)
- @fog_x = x
- @fog_y = y
- end
- #--------------------------------------------------------------------------
- # * Calculate X coordinate for fog display
- # bitmap : Fog bitmap
- #--------------------------------------------------------------------------
- def calc_fog_x(bitmap)
- return bitmap == nil ? 0 : @fog_x / 8
- end
- #--------------------------------------------------------------------------
- # * Calculate Y coordinate for fog display
- # bitmap : Fog bitmap
- #--------------------------------------------------------------------------
- def calc_fog_y(bitmap)
- return bitmap == nil ? 0 : @fog_y / 8
- end
- #--------------------------------------------------------------------------
- # * Scroll Down (Definition added)
- # distance : scroll distance
- #--------------------------------------------------------------------------
- def scroll_down(distance)
- last_y = @display_y
- _exmapln_scroll_down(distance)
- if loop_vertical?
- @fog_y += distance
- else
- @fog_y += @display_y - last_y
- end
- end
- #--------------------------------------------------------------------------
- # * Scroll Left (Definition added)
- # distance : scroll distance
- #--------------------------------------------------------------------------
- def scroll_left(distance)
- last_x = @display_x
- _exmapln_scroll_left(distance)
- if loop_horizontal?
- @fog_x -= distance
- else
- @fog_x += @display_x - last_x
- end
- end
- #--------------------------------------------------------------------------
- # * Scroll Right (Definition added)
- # distance : scroll distance
- #--------------------------------------------------------------------------
- def scroll_right(distance)
- last_x = @display_x
- _exmapln_scroll_right(distance)
- if loop_horizontal?
- @fog_x += distance
- else
- @fog_x += @display_x - last_x
- end
- end
- #--------------------------------------------------------------------------
- # * Scroll Up (Definition added)
- # distance : scroll distance
- #--------------------------------------------------------------------------
- def scroll_up(distance)
- last_y = @display_y
- _exmapln_scroll_up(distance)
- if @fog != nil
- if loop_vertical?
- @fog_y -= distance
- else
- @fog_y += @display_y - last_y
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Update Fog
- #--------------------------------------------------------------------------
- def update_fog
- @fog_x += @fog_sx * 2
- @fog_y += @fog_sy * 2
- end
- end
- class Spriteset_Map
- alias _exmapln_initialize initialize unless $@
- alias _exmapln_dispose dispose unless $@
- alias _exmapln_update update unless $@
- #--------------------------------------------------------------------------
- # * Object Initialization (Definition added)
- #--------------------------------------------------------------------------
- def initialize
- create_fog
- _exmapln_initialize
- end
- #--------------------------------------------------------------------------
- # * Create Fog
- #--------------------------------------------------------------------------
- def create_fog
- @fog = Plane.new
- if $game_map.fog != nil
- @fog.z = $game_map.fog[4]
- @fog.opacity = $game_map.fog[5]
- @fog.blend_type = $game_map.fog[6]
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose (Definition added)
- #--------------------------------------------------------------------------
- def dispose
- _exmapln_dispose
- @fog.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Definition added)
- #--------------------------------------------------------------------------
- def update
- _exmapln_update
- update_fog
- end
- #--------------------------------------------------------------------------
- # * Update Fog
- #--------------------------------------------------------------------------
- def update_fog
- if @fog_name != $game_map.fog[1]
- @fog_name = $game_map.fog[1]
- if @fog.bitmap != nil
- @fog.bitmap.dispose
- @fog.bitmap = nil
- end
- if @fog_name != ""
- case EXMAP_ATPLN_FOLDER
- when 0
- @fog.bitmap = Cache.system(@fog_name)
- when 1
- @fog.bitmap = Cache.parallax(@fog_name)
- when 2
- @fog.bitmap = Cache.picture(@fog_name)
- when 3
- @fog.bitmap = Cache.animation(@fog_name, 0)
- end
- end
- Graphics.frame_reset
- end
- @fog.ox = $game_map.calc_fog_x(@fog.bitmap)
- @fog.oy = $game_map.calc_fog_y(@fog.bitmap)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment