rect = Rect.new(0,0,32,32)
source = Rect.new(0,0,32,32)
i = 0
x = 0
y = 0
z = 0
data = nil
wall = nil
for x in 0...@map_data.xsize
for y in 0...@map_data.ysize
rect.x = x*32
rect.y = y*32
source.x = ((@map_data[x,y,0] - 384) % 8) * 32
source.y = ((@map_data[x,y,0] - 384) / 8) * 32
@bitmap.stretch_blt(rect,@tileset,source)
for z in 0..2
data = @map_data[x,y,z]
if @terrain[data] == 2
if @terrain[@map_data[[x+1,@map_data.xsize-1].min,y,z].to_i] != 2
for i in 0...@columns
wall = SWall.new(@viewport,@columns)
wall.map_x = x * 32 + 32
wall.map_y = y * 32 + (@columns-i) * 32 / @columns
wall.bitmap = @tileset
wall.z = wall.map_y
wall.side = 1 * $game_system.hidewalls
wall.set_src(@terrain, data, i)
wall.ox = 32 / @columns / 2 - 1
if @vertical.key?(wall.map_y)
@vertical[wall.map_y].push(wall)
else
@vertical[wall.map_y] = [wall]
end
end
end
if @terrain[@map_data[[x-1,0].max,y,z].to_i] != 2
for i in 0...@columns
wall = SWall.new(@viewport,@columns)
wall.map_x = x * 32
wall.map_y = y * 32 + (@columns-i) * 32 / @columns
wall.bitmap = @tileset
wall.mirror = true
wall.set_src(@terrain, data, i)
wall.z = wall.map_y
wall.side = -1 * $game_system.hidewalls
wall.ox = 32 / @columns / 2
if @vertical.key?(wall.map_y)
@vertical[wall.map_y].push(wall)
else
@vertical[wall.map_y] = [wall]
end
end
end
end
if @terrain[data] == 1 and
(y+1 == @map_data.ysize or
@map_data[x,y+1,z] != data + 8)
wall = Wall.new(@viewport,1,@map_data)
wall.map_x = x * 32 + 16
wall.map_y = y * 32 + 32 + 1
wall.real_y = y
wall.bitmap = @tileset
wall.set_src(@terrain, data)
wall.ox = 15
wall.z = wall.map_y
if @horizontal.key?(wall.map_y)
@horizontal[wall.map_y].push(wall)
else
@horizontal[wall.map_y] = [wall]
end
end
end
end
end
for i in [email protected]
@sprites.bitmap = @bitmap
@sprites.src_rect.set(0,i,@bitmap.width,@height)
if i >= @scroll_y / @height
@sprites.src_rect.height *= 2
end
end
end
def update
if $game_system.coord
x = $game_system.coord[0]
y = $game_system.coord[1]
source = Rect.new(0,0,32,32)
rect = Rect.new(x*32,y*32,32,32)
for z in 0..2
if not [1,2].include?(@terrain[@map_data[x,y,z]])
source.x = ((@map_data[x,y,z] - 384) % 8) * 32
source.y = ((@map_data[x,y,z] - 384) / 8) * 32
@bitmap.stretch_blt(rect,@tileset,source)
end
end
$game_system.coord = nil
end
if $game_system.need_refresh
$game_system.new_angle = false
$game_system.need_refresh = false
refresh
return
end
if $game_system.new_zoom
$game_system.new_zoom = false
refresh(false)
return
end
if $game_system.new_angle
@sprites.each {|w|
w.zoom_x = $game_system.screen2zoom(w.y+1)
if w.zoom_x > 1
w.zoom_y = w.zoom_x
end
w.x = 320
}
x = @ox
y = @oy
@ox += 1
@oy += 1
self.ox = x
self.oy = y
$game_system.new_angle = false
end
end
def dispose
@horizontal.each{ |i, c|
c.each{ |w|
w.dispose}}
@vertical.each{ |i, c|
c.each{ |w|
w.dispose}}
@sprites.each{ |w|
w.dispose}
@bitmap.dispose
end
end
class SWall < Wall
def set_src(terrain,tile,i)
super
self.src_rect.height -= 32
self.oy -= 32
end
end
class Game_Map
attr_reader :W3D
alias scroll_down_W3D scroll_down
alias scroll_left_W3D scroll_left
alias scroll_right_W3D scroll_right
alias scroll_up_W3D scroll_up
alias setup_W3D setup
def scroll_down(distance)
if $game_map.W3D
@display_y += distance
else
scroll_down_W3D(distance)
end
end
def scroll_left(distance)
if $game_map.W3D
@display_x -= distance
else
scroll_left_W3D(distance)
end
end
def scroll_right(distance)
if $game_map.W3D
@display_x += distance
else
scroll_right_W3D(distance)
end
end
def scroll_up(distance)
if $game_map.W3D
@display_y -= distance
else
scroll_up_W3D(distance)
end
end
def name
return $data_maps[@map_id].name
end
def setup(id)
setup_W3D(id)
@W3D = false
for part in self.name.split("[")
case part
when /#(.*)\]/
$game_system.angle = $1.to_i
when "W3D]"
@W3D = true
when /-(.*)\]/
$game_system.hidewalls = $1.to_i
end
end
end
end
class Game_Character
alias screen_z_W3D screen_z
def screen_z(height = 0)
if $game_map.W3D
if @always_on_top
return $game_map.height * 32 + 10
end
return @real_y / 4 + 33
else
screen_z_W3D(height)
end
end
end
class Game_Player
alias center_W3D center
def center(x, y)
if $game_map.W3D
$game_map.display_x = x * 128 - CENTER_X
$game_map.display_y = y * 128 - CENTER_Y
else
center_W3D(x, y)
end
end
end
class Sprite_Character
alias update_W3D update
def update
update_W3D
return unless $game_map.W3D
self.y = $game_system.screen2W3D_y(self.y - $game_system.scroll_y)
self.zoom_x = self.zoom_y = $game_system.screen2zoom(self.y)
self.x = 320 + (self.zoom_x * (self.x - 320))
end
end
class Spriteset_Map
def initialize
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
if $game_map.W3D
@tilemap = W3DTilemap.new(@viewport1)
@tilemap.terrain = $game_map.terrain_tags
else
@tilemap = Tilemap.new(@viewport1)
end
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names
@tilemap.autotiles = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
@fog = Plane.new(@viewport1)
@fog.z = 3000
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events)
@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))
end
@timer_sprite = Sprite_Timer.new
update
end
###########重定义update 更改远景图更新速度 直接复制默认的 顺着箭头往下走
def update
# 远景与现在的情况有差异发生的情况下 ↓
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 @panorama.bitmap != nil# ↓
@panorama.bitmap.dispose# ↓
@panorama.bitmap = nil# ↓
end
if @panorama_name != ""# ↓
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @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
# 刷新远景平面# ↓
@panorama.ox = $game_map.display_x / 8 #这里更改X速度 ←
@panorama.oy = $game_map.display_y * 0 #这里更改Y速度 ←
# 刷新雾平面
@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
end 作者: 紫英晓狼1130 时间: 2013-9-30 18:37
确定图块没问题?
鼠标和3D脚本都是比较糟糕的…作者: 天皇子夜 时间: 2013-10-2 18:56