Advertisement
LiTTleDRAgo

[RGSS/2/3] DRG Fade Effect Room Ver 1.00

Apr 13th, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.84 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # DRG Fade Effect Room
  3. # Version: 1.16
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #==============================================================================
  7. # ** Game_Event
  8. #------------------------------------------------------------------------------
  9. #  This class deals with events. It handles functions including event page
  10. #  switching via condition determinants, and running parallel process events.
  11. #  It's used within the Game_Map class.
  12. #==============================================================================
  13. class Game_Event < Game_Character
  14.   #--------------------------------------------------------------------------
  15.   # * Public Instance Variables
  16.   #--------------------------------------------------------------------------
  17.   attr_reader :event
  18. end
  19. #==============================================================================
  20. # ** Spriteset_Map
  21. #------------------------------------------------------------------------------
  22. #  This class brings together map screen sprites, tilemaps, etc.
  23. #  It's used within the Scene_Map class.
  24. #==============================================================================
  25. class Spriteset_Map
  26.   #--------------------------------------------------------------------------
  27.   # * Alias Listing
  28.   #--------------------------------------------------------------------------
  29.   alias_method :drg132_update, :update if !method_defined?(:drg132_update)
  30.   #--------------------------------------------------------------------------
  31.   # * Objects Initialization
  32.   #--------------------------------------------------------------------------
  33.   def init_fadesprite
  34.     @fade_sprite = []
  35.     $game_map.events.keys.sort.each {|i|
  36.       next unless $game_map.events[i].event.name =~ /ObjectMask/i
  37.       $game_map.events[i].list.each {|list| parameter = list.parameters[0]
  38.       next if parameter.nil?
  39.       if parameter =~ /<Color = (\d+), (\d+), (\d+)>/i
  40.         j = [$1.to_i,$2.to_i,$3.to_i,255]
  41.       elsif parameter =~ /<Color = (\d+), (\d+), (\d+), (\d+)>/i
  42.         j = [$1.to_i,$2.to_i,$3.to_i,$4.to_i]
  43.       end
  44.       @fade_color = Color.new(*j) if !j.nil? && j[0..2] != [0]*3
  45.       if parameter =~ /\((\d+),(\d+),(\d+),(\d+)\)/
  46.         a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i
  47.         parameter =~ /\[(\d+),(\d+),(\d+),(\d+)\]/
  48.         e,f,g,h = $1.to_i,$2.to_i,$3.to_i,$4.to_i
  49.       elsif parameter =~ /\(\[(\d+),(\d+),(\d+),(\d+)\]\)/
  50.         a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i
  51.         e,f,g,h = a,b,c,d
  52.       end
  53.       next unless !a.nil? && a.is_a?(Numeric)
  54.       s = Sprite.new(@viewport1)
  55.       s.x, s.y, s.z, tc = a*32+16, b*32+16, 998, Color.new(*[0]*4)
  56.       s.bitmap = Bitmap.new((c-a)*32,(d-b)*32)
  57.       s.bitmap.fill_rect(0,0,s.bitmap.width,s.bitmap.height,@fade_color)
  58.       if parameter =~ /<(\d+),(\d+),(\d+),(\d+)>/
  59.         a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i
  60.         s.bitmap.fill_rect(a*32-s.x+16,b*32-s.y+16,(c-a)*32,(d-b)*32,tc)
  61.       end
  62.       mask = [s,[e,f,g,h],[],fade_coord_player]
  63.       if parameter =~ /{(\d+),(\d+),(\d+),(\d+)}/
  64.         mask[2] = [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
  65.       end
  66.       if parameter =~ /<{(\d+),(\d+),(\d+),(\d+)}>/
  67.         e,f,g,h = $1.to_i,$2.to_i,$3.to_i,$4.to_i
  68.         s.bitmap.fill_rect(e*32-s.x+16,f*32-s.y+16,(g-e)*32,(h-f)*32,tc)
  69.         mask[2] = [e,f,g,h]
  70.       end
  71.       mask[0].ox, mask[0].oy = $game_map.display_x/4, $game_map.display_y/4
  72.       mask[0].opacity = (mask[1][0]..mask[1][2]) === mask[3][0] &&
  73.           (mask[1][1]..mask[1][3]) === mask[3][1] &&
  74.           (mask[2].empty? || !((mask[2][0]..mask[2][2]) === mask[3][0]&&
  75.           (mask[2][1]..mask[2][3]) === mask[3][1])) ? 0 : 255
  76.       @fade_sprite << mask   }}
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # * Frame Update
  80.   #--------------------------------------------------------------------------
  81.   def update
  82.     @fade_sprite.nil? ? init_fadesprite : @fade_sprite.each {|mask|
  83.       mask[0].ox, mask[0].oy = $game_map.display_x/4, $game_map.display_y/4
  84.       a = fade_coord_player
  85.       a = [(mask[1][0]..mask[1][2]) === a[0] &&
  86.           (mask[1][1]..mask[1][3]) === a[1] &&
  87.           (mask[2].empty? ||! ((mask[2][0]..mask[2][2]) === a[0] &&
  88.           (mask[2][1]..mask[2][3]) === a[1])), mask[0].opacity]
  89.       mask[0].opacity = a[0] ? [a[1] - 16, 0].max : [a[1] + 8, 255].min }
  90.     drg132_update  
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * Fade Coord Player
  94.   #--------------------------------------------------------------------------
  95.   def fade_coord_player
  96.     return [$game_player.real_x/128, $game_player.real_y/128]
  97.     return [$game_player.x, $game_player.y]
  98.   end
  99. end
  100.  
  101. $drg_fade_room = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement