$VIPArcherScript ||= {};$VIPArcherScript[:black_room] = 20150211
module VIPArcher end
module VIPArcher::BlackRoom
Z = 999
SW = 1
Edge = 16
Room_Color = Color.new(0,0,0)
Event_Name = 'Black_Room'
Opacity_Speed = 17
end
class Sprite_BlackRoom < Sprite
include VIPArcher::BlackRoom
def initialize(rect,check_rect,color,viewport)
super(viewport)
@check_rect, @color = check_rect,color
if rect.is_a?(Rect)
self.x, self.y, self.z = rect.x * 32, rect.y * 32, Z
width, height = rect.width - rect.x + 1,rect.height - rect.y + 1
set_bitmap(width * 32,height * 32)
elsif rect.is_a?(Array)
self.x, self.y, self.z = rect[1] * 32, rect[2] * 32, Z
set_bitmap(rect[0])
end
end
def set_bitmap(*args)
case args.size
when 1
self.bitmap = Cache.parallax(args[0])
when 2
self.bitmap = Bitmap.new(args[0], args[1])
rect = Rect.new(Edge, Edge, args[0] - Edge * 2, args[1] - Edge * 2)
self.bitmap.fill_rect(rect, @color)
end
end
def dispose
super
self.bitmap.dispose
end
def character_pos?
$game_player.x > @check_rect.width || $game_player.x < @check_rect.x ||
$game_player.y > @check_rect.height || $game_player.y < @check_rect.y
end
def update_opacity
self.opacity += character_pos? ? Opacity_Speed : - Opacity_Speed
self.opacity = 0 if $game_switches[SW]
end
def update_position
self.ox = $game_map.display_x * 32
self.oy = $game_map.display_y * 32
end
def update
super
update_opacity
update_position
end
end
class Spriteset_Map
include VIPArcher::BlackRoom
alias black_room_create_characters create_characters
def create_characters
black_room_create_characters
room_sprite_dispose if @black_room_sprites
@black_room_sprites = []
$game_map.events.values.each do |event|
if event.instance_variable_get(:@event).name =~ /#{Event_Name}/i
return if event.list.nil?
event.list.each { |command| get_setup(command) }
end
end
end
def get_setup(command)
return unless command.code == 108 or 408
command.parameters.each {|line|get_rect_setup(line);get_bitmap_setup(line)}
end
def get_bitmap_setup(line)
if line =~ /<name\s*=\s*(\S+?)\s*x:\s*(\d+?)\s*y:\s*(\d+)>/i
rect = [$1,$2.to_i,$3.to_i]
if line =~ /\[(\d+.*?)\]/; x = $1.split(',')
check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
end
sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1)
sprite.opacity = 0 unless sprite.character_pos?
@black_room_sprites.push(sprite)
end
end
def get_rect_setup(line)
@color = eval($1) if line =~ /<color\s*=\s*(.*?)\s*>/i
@color ||= Room_Color
if line =~ /<(\d+.*?)>/; x = $1.split(',')
check_rect = rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
if line =~ /\[(\d+.*?)\]/; x = $1.split(',')
check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
end
sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1)
sprite.opacity = 0 unless sprite.character_pos?
@black_room_sprites.push(sprite)
end
end
alias black_room_dispose dispose
def dispose
black_room_dispose
room_sprite_dispose
end
def room_sprite_dispose
@black_room_sprites.each {|sprite| sprite.dispose }
end
alias black_room_update update
def update
black_room_update
@black_room_sprites.each {|sprite| sprite.update }
end
end