#==============================================================================
# 本脚本来自[url]www.66rpg.com[/url],使用前请参考制作录像
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
# 处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================
class Spriteset_Map
attr_accessor :panorama
attr_accessor :panorama2
attr_accessor :plane
attr_accessor :plane2
Map_width = 320
Map_height = 240
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 800, 600)
@viewport2 = Viewport.new(0, 0, 800, 600)
@viewport3 = Viewport.new(0, 0, 800, 600)
#@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@path = "map/"#远景图所在路径
@panorama = []
@panorama2 = []
@plane = Plane.new(@viewport1)
@plane.z = -1000
@plane2 = Plane.new(@viewport1)
@plane2.z = 0
@panorama_status = []
@type = ($game_map.width + $game_map.height > 160 ) ? true : false
for i in 0..8
@panorama[i] = Sprite.new(@viewport1)
@panorama[i].z = -1000
@panorama2[i] = Sprite.new(@viewport1)
@panorama2[i].z = 0
@panorama_status[i] = i
end
#图像位置初始化
update_xy
# 生成雾平面
@fog = Plane.new(@viewport1)
@fog.z = 0
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
# 释放远景平面
for i in 0..8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
end
@panorama[i].dispose
@panorama2[i].dispose
end
if @plane.bitmap != nil
@plane.bitmap.dispose
end
if @plane2.bitmap != nil
@plane2.bitmap.dispose
end
@plane.dispose
@plane2.dispose
# 释放雾平面
@fog.dispose
# 释放角色活动块
for sprite in @character_sprites
sprite.dispose
end
# 释放天候
#@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 默认刷新画面
#--------------------------------------------------------------------------
def update_default
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @plane.bitmap != nil
@plane.bitmap.dispose
@plane2.bitmap.dispose
@plane.bitmap = nil
@plane2.bitmap = nil
end
if @panorama_name != ""
@plane.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
@plane2.bitmap = RPG::Cache.panorama(@panorama_name+"_2", @panorama_hue)
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
@plane.ox = $game_map.display_x / 4
@plane.oy = $game_map.display_y / 4
@plane2.ox = @plane.ox
@plane2.oy = @plane.oy
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
# 刷新天候图形
#@weather.type = $game_screen.weather_type
#@weather.max = $game_screen.weather_max
#@weather.ox = $game_map.display_x / 4
#@weather.oy = $game_map.display_y / 4
#@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
if @type == false
update_default
return
end
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
# 修正display_x和display_y,避免出现黑底
$game_map.display_x = $game_map.display_x-($game_map.display_x/4%Map_width)*4+Map_width/2*4
$game_map.display_y = $game_map.display_y-($game_map.display_y/4%Map_height)*4+Map_height/2*4
# 开始描绘远景图
update_panorama
# 记录旧坐标便于刷新ox和oy
@old_x = $game_map.display_x
@old_y = $game_map.display_y
# 修正如果地图切换时,主角在地图边缘边缘时出现黑底的问题
if ($game_map.display_x/4+@panorama[2].x) >= ($game_map.width*32)
$game_map.display_x-=800
end
if ($game_map.display_y/4+@panorama[6].y) >= ($game_map.height*32)
$game_map.display_y-=600
end
#防止进入地图时角色在最左边找不到人的BUG
if $game_player.x <= 10
$game_map.display_x = 0
end
#防止进入地图时角色在最上边找不到人的BUG
if $game_player.y <= 10
$game_map.display_y = 0
#防止进入地图时角色在最下面时最后一个图片高度不为120的情况
elsif ($game_map.height * 32)%240 != 0
if ($game_map.height * 32)%240 < Map_height / 2
$game_map.display_y -=Map_height
end
end
end
# 雾与现在的情况有差异的情况下
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
#如果水平移动
if @old_x != $game_map.display_x
v = @old_x / 4
d = $game_map.display_x / 4
for i in 0..8
@panorama[i].ox -= v - d
@panorama2[i].ox -= v - d
end
@old_x = $game_map.display_x
end
#如果竖直移动
if @old_y != $game_map.display_y
v = @old_y / 4
d = $game_map.display_y / 4
for i in 0..8
@panorama[i].oy -= v-d
@panorama2[i].oy -= v-d
end
@old_y = $game_map.display_y
end
#重新计算图像布局
x = $game_map.display_x / 4
a = x / Map_width + 1
y = $game_map.display_y / 4
b = y / Map_height + 1
if @old_plx != a
if @old_ply != b
update_ab(x,y,a,b)
else
update_a(x,y,a,b)
end
end
if @old_ply != b
if @old_plx != a
update_ab(x,y,a,b)
else
update_b(x,y,a,b)
end
end
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
# 刷新天候图形
#@weather.type = $game_screen.weather_type
#@weather.max = $game_screen.weather_max
#@weather.ox = $game_map.display_x / 4
#@weather.oy = $game_map.display_y / 4
#@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
end
#==============================================================================
# 精灵图像水平变更
#==============================================================================
def update_a(x,y,a,b)
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width )
d = a+1
else
d = false
end
if b-1 >= 0
e = b-1
else
e = false
end
he = $game_map.height*32
if b+1 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
f = b+1
else
f = false
end
if a < @old_plx
for i in 0..8
case @panorama_status[i]
when 2
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 5
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
#将数组值迭代给@old_panorama_status,不可直接赋值
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[1]
@panorama_status[1] = @old_panorama_status[2]
@panorama_status[2] = @old_panorama_status[0]
@panorama_status[3] = @old_panorama_status[4]
@panorama_status[4] = @old_panorama_status[5]
@panorama_status[5] = @old_panorama_status[3]
@panorama_status[6] = @old_panorama_status[7]
@panorama_status[7] = @old_panorama_status[8]
@panorama_status[8] = @old_panorama_status[6]
else
for i in 0..8
case @panorama_status[i]
when 0
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 3
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 6
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[2]
@panorama_status[1] = @old_panorama_status[0]
@panorama_status[2] = @old_panorama_status[1]
@panorama_status[3] = @old_panorama_status[5]
@panorama_status[4] = @old_panorama_status[3]
@panorama_status[5] = @old_panorama_status[4]
@panorama_status[6] = @old_panorama_status[8]
@panorama_status[7] = @old_panorama_status[6]
@panorama_status[8] = @old_panorama_status[7]
end
#更新图像位置
update_xy
#图像传送坐标复位
m = @panorama[0].ox
if @panorama[0].ox < 0
for i in 0..8
@panorama[i].ox = Map_width+m
@panorama2[i].ox = Map_width+m
end
else
for i in 0..8
@panorama[i].ox = -(Map_width)+m
@panorama2[i].ox = -(Map_width)+m
end
end
#更新横向旧标识
@old_plx = a
end
#==============================================================================
# 精灵图像竖直水平变更
#==============================================================================
def update_ab(x,y,a,b)
if a < @old_plx and b < @old_ply
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width)
d = a+1
else
d = false
end
he = $game_map.height*32
if b+2 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
e = b+2
else
e = false
end
if b+1 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
f = b+1
else
f = false
end
for i in 0..8
case @panorama_status[i]
when 2
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 5
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[1]
@panorama_status[1] = @old_panorama_status[2]
@panorama_status[2] = @old_panorama_status[0]
@panorama_status[3] = @old_panorama_status[4]
@panorama_status[4] = @old_panorama_status[5]
@panorama_status[5] = @old_panorama_status[3]
@panorama_status[6] = @old_panorama_status[7]
@panorama_status[7] = @old_panorama_status[8]
@panorama_status[8] = @old_panorama_status[6]
elsif a < @old_plx and b > @old_ply
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width)
d = a+1
else
d = false
end
if b-2 >= 0
e = b-2
else
e = false
end
if b-1 >= 0
f = b-1
else
f = false
end
for i in 0..8
case @panorama_status[i]
when 2
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 5
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[1]
@panorama_status[1] = @old_panorama_status[2]
@panorama_status[2] = @old_panorama_status[0]
@panorama_status[3] = @old_panorama_status[4]
@panorama_status[4] = @old_panorama_status[5]
@panorama_status[5] = @old_panorama_status[3]
@panorama_status[6] = @old_panorama_status[7]
@panorama_status[7] = @old_panorama_status[8]
@panorama_status[8] = @old_panorama_status[6]
elsif a > @old_plx and b < @old_ply
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width)
d = a+1
else
d = false
end
he = $game_map.height*32
if b+2 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
e = b+2
else
e = false
end
if b+1 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
f = b+1
else
f = false
end
for i in 0..8
case @panorama_status[i]
when 0
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 3
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 6
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
else
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width)
d = a+1
else
d = false
end
if b-2 >= 0
e = b-2
else
e = false
end
if b-1 >= 0
f = b-1
else
f = false
end
for i in 0..8
case @panorama_status[i]
when 0
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 3
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 6
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[2]
@panorama_status[1] = @old_panorama_status[0]
@panorama_status[2] = @old_panorama_status[1]
@panorama_status[3] = @old_panorama_status[5]
@panorama_status[4] = @old_panorama_status[3]
@panorama_status[5] = @old_panorama_status[4]
@panorama_status[6] = @old_panorama_status[8]
@panorama_status[7] = @old_panorama_status[6]
@panorama_status[8] = @old_panorama_status[7]
end
update_xy
m = @panorama[0].ox
if @panorama[0].ox < 0
for i in 0..8
@panorama[i].ox = Map_width+m
@panorama2[i].ox = Map_width+m
end
else
for i in 0..8
@panorama[i].ox = -(Map_width)+m
@panorama2[i].ox = -(Map_width)+m
end
end
@old_plx = a
end
#==============================================================================
# 精灵图像竖直变更
#==============================================================================
def update_b(x,y,a,b)
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? (wi / Map_width - 1) : wi / Map_width)
d = a+1
else
d = false
end
if b-1 >= 0
e = b-1
else
e = false
end
he = $game_map.height*32
if b+1 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height)
f = b+1
else
f = false
end
if b < @old_ply
for i in 0..8
case @panorama_status[i]
when 6
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 7
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{a}-#{e}", @panorama_hue) if a.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{a}-#{e}", @panorama_hue) if a.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[3]
@panorama_status[1] = @old_panorama_status[4]
@panorama_status[2] = @old_panorama_status[5]
@panorama_status[3] = @old_panorama_status[6]
@panorama_status[4] = @old_panorama_status[7]
@panorama_status[5] = @old_panorama_status[8]
@panorama_status[6] = @old_panorama_status[0]
@panorama_status[7] = @old_panorama_status[1]
@panorama_status[8] = @old_panorama_status[2]
else
for i in 0..8
case @panorama_status[i]
when 0
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 1
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{a}-#{f}", @panorama_hue) if a.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{a}-#{f}", @panorama_hue) if a.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
when 2
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
if @panorama2[i].bitmap != nil
@panorama2[i].bitmap.dispose
@panorama2[i].bitmap = nil
end
@panorama[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[i].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum) #and FileTest.directory?("Graphics/Panoramas/map/#{@panorama_name}_2")
end
end
@old_panorama_status = @panorama_status.dup
@panorama_status[0] = @old_panorama_status[6]
@panorama_status[1] = @old_panorama_status[7]
@panorama_status[2] = @old_panorama_status[8]
@panorama_status[3] = @old_panorama_status[0]
@panorama_status[4] = @old_panorama_status[1]
@panorama_status[5] = @old_panorama_status[2]
@panorama_status[6] = @old_panorama_status[3]
@panorama_status[7] = @old_panorama_status[4]
@panorama_status[8] = @old_panorama_status[5]
end
update_xy
n = @panorama[0].oy
if @panorama[0].oy < 0
for i in 0..8
@panorama[i].oy = Map_height+n
@panorama2[i].oy = Map_height+n
end
else
for i in 0..8
@panorama[i].oy = -(Map_height)+n
@panorama2[i].oy = -(Map_height)+n
end
end
@old_ply = b
end
#==============================================================================
# 设置远景图像
#==============================================================================
def update_panorama
for i in 0..8
if @panorama[i].bitmap != nil
@panorama[i].bitmap.dispose
@panorama[i].bitmap = nil
end
end
if @panorama_name != ""
x = $game_map.display_x / 4
a = x / Map_width + 1
y = $game_map.display_y / 4
b = y / Map_height + 1
@old_plx = a
@old_ply = b
if a-1 >= 0
c = a-1
else
c = false
end
wi = $game_map.width*32
if a+1 <= (wi%Map_width == 0 ? wi / Map_width - 1 : wi / Map_width)and wi > 640
d = a+1
else
d = false
end
if b-1 >= 0
e = b-1
else
e = false
end
he = $game_map.height*32
if b+1 <= (he%Map_height == 0 ? he / Map_height - 1 : he / Map_height) and he > 480
f = b+1
else
f = false
end
@panorama2[0].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[1].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{a}-#{e}", @panorama_hue) if a.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[2].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama2[3].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[4].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{a}-#{b}", @panorama_hue) if a.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[5].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama2[6].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[7].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{a}-#{f}", @panorama_hue) if a.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama2[8].bitmap = RPG::Cache.panorama(@path+@panorama_name+"_2/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama[0].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{e}", @panorama_hue) if c.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama[1].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{a}-#{e}", @panorama_hue) if a.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama[2].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{e}", @panorama_hue) if d.is_a?(Fixnum) and e.is_a?(Fixnum)
@panorama[3].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{b}", @panorama_hue) if c.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama[4].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{a}-#{b}", @panorama_hue) if a.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama[5].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{b}", @panorama_hue) if d.is_a?(Fixnum) and b.is_a?(Fixnum)
@panorama[6].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{c}-#{f}", @panorama_hue) if c.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama[7].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{a}-#{f}", @panorama_hue) if a.is_a?(Fixnum) and f.is_a?(Fixnum)
@panorama[8].bitmap = RPG::Cache.panorama(@path+@panorama_name+"/#{d}-#{f}", @panorama_hue) if d.is_a?(Fixnum) and f.is_a?(Fixnum)
end
Graphics.frame_reset
end
#==============================================================================
# 设置精灵位置
#==============================================================================
def update_xy
for i in 0..8
case @panorama_status[i]
when 0
@panorama[i].x = (640-Map_width)/2-Map_width
@panorama[i].y = (480-Map_height)/2-Map_height
@panorama2[i].x = (640-Map_width)/2-Map_width
@panorama2[i].y = (480-Map_height)/2-Map_height
when 1
@panorama[i].x = (640-Map_width)/2
@panorama[i].y = (480-Map_height)/2-Map_height
@panorama2[i].x = (640-Map_width)/2
@panorama2[i].y = (480-Map_height)/2-Map_height
when 2
@panorama[i].x = (640-Map_width)/2+Map_width
@panorama[i].y = (480-Map_height)/2-Map_height
@panorama2[i].x = (640-Map_width)/2+Map_width
@panorama2[i].y = (480-Map_height)/2-Map_height
when 3
@panorama[i].x = (640-Map_width)/2-Map_width
@panorama[i].y = (480-Map_height)/2
@panorama2[i].x = (640-Map_width)/2-Map_width
@panorama2[i].y = (480-Map_height)/2
when 4
@panorama[i].x = (640-Map_width)/2
@panorama[i].y = (480-Map_height)/2
@panorama2[i].x = (640-Map_width)/2
@panorama2[i].y = (480-Map_height)/2
when 5
@panorama[i].x = (640-Map_width)/2+Map_width
@panorama[i].y = (480-Map_height)/2
@panorama2[i].x = (640-Map_width)/2+Map_width
@panorama2[i].y = (480-Map_height)/2
when 6
@panorama[i].x = (640-Map_width)/2-Map_width
@panorama[i].y = (480-Map_height)/2+Map_height
@panorama2[i].x = (640-Map_width)/2-Map_width
@panorama2[i].y = (480-Map_height)/2+Map_height
when 7
@panorama[i].x = (640-Map_width)/2
@panorama[i].y = (480-Map_height)/2+Map_height
@panorama2[i].x = (640-Map_width)/2
@panorama2[i].y = (480-Map_height)/2+Map_height
when 8
@panorama[i].x = (640-Map_width)/2+Map_width
@panorama[i].y = (480-Map_height)/2+Map_height
@panorama2[i].x = (640-Map_width)/2+Map_width
@panorama2[i].y = (480-Map_height)/2+Map_height
end
end
end#结束update_xy
end
#==============================================================================
# 本脚本来自[url]www.66rpg.com[/url],使用前请参考制作录像
#==============================================================================