class Tilemap_Debug < Sprite
def initialize(viewport, tilemap)
super(viewport)
@tilemap = tilemap
self.bitmap= Bitmap.new(@tilemap.map_data.xsize * 32,
@tilemap.map_data.ysize * 32)
self.z=800
refresh
end
def dispose
self.bitmap.dispose if self.bitmap!=nil
super
end
def passable_color
return Color.new(64, 192, 64, 64) # green
end
def non_passable_color
return Color.new(255, 72, 0, 64) # red
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# background mask
self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
Color.new(0, 0, 0, 32))
for x in [email]0...@tilemap.map_data.xsize[/email]
for y in [email]0...@tilemap.map_data.ysize[/email]
draw_mapinfo(x, y)
end
end
end
def draw_mapinfo(x, y)
# 通行性
self.bitmap.fill_rect(Rect.new(x*32, y*32, 32, 32),
$game_map.passable?(x, y, 0) ? passable_color : non_passable_color)
# 地图标记。选最大的那个显示
self.bitmap.draw_text(Rect.new(x*32, y*32, 32, 32),
$game_map.terrain_tag(x, y).to_s, 1)
end
end
class Spriteset_Map
alias viktor_td_update update
def update
if @td==nil
@td=Tilemap_Debug.new(@viewport1, @tilemap)
end
@td.ox=$game_map.display_x / 4
@td.oy=$game_map.display_y / 4
@td.update
viktor_td_update
end
alias viktor_td_dispose dispose
def dispose
@td.dispose
viktor_td_dispose
end
end
class Tilemap_Debug < Sprite
def initialize(viewport, tilemap)
super(viewport)
@tilemap = tilemap
self.bitmap= Bitmap.new(@tilemap.map_data.xsize * 32,
@tilemap.map_data.ysize * 32)
self.z=800
refresh
end
def dispose
self.bitmap.dispose if self.bitmap!=nil
super
end
def passable_color
return Color.new(64, 192, 64, 64) # green
end
def non_passable_color
return Color.new(255, 72, 0, 64) # red
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# background mask
self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
Color.new(0, 0, 0, 32))
for x in [email]0...@tilemap.map_data.xsize[/email]
for y in [email]0...@tilemap.map_data.ysize[/email]
draw_mapinfo(x, y)
end
end
end
def draw_mapinfo(x, y)
# 通行性
self.bitmap.fill_rect(Rect.new(x*32, y*32, 32, 32),
$game_map.passable?(x, y, 0) ? passable_color : non_passable_color)
# 地图标记。选最大的那个显示
self.bitmap.draw_text(Rect.new(x*32, y*32, 32, 32),
$game_map.terrain_tag(x, y).to_s, 1)
end
end
class Spriteset_Map
alias viktor_td_update update
def update
if @td==nil
@td=Tilemap_Debug.new(@viewport1, @tilemap)
end
@td.ox=$game_map.display_x / 4
@td.oy=$game_map.display_y / 4
@td.update
viktor_td_update
end
alias viktor_td_dispose dispose
def dispose
@td.dispose
viktor_td_dispose
end
end