自己改这些 #-------------------------------------------------------------------------- class Game_System attr_accessor :minimap_visible attr_accessor :minimap_corner alias initialize_minimap initialize def initialize @minimap_visible = true # 一开始就显示小地图 @minimap_corner = 1 # 小地图的位置 (1,2,3,4) initialize_minimap end end 在运行时改变小地图 显示小地图 $game_system.minimap_visible = true
不显示小地图 $game_system.minimap_visible = false
换位置 $game_system.minimap_corner = 1 # 2, 3, 4
使用自己的 border, 必须改变一些 (在 Spriteset_MiniMap 内) bt = 25 # the border size at the top bl = 5 # the border size at the left br = 5 # the border size at the right bb= 5 # the border size at the bottom 第一步:为了安全,请大家先试用在新的 project 第二步:下载这个图片到 "Graphics\Characters"。(大家可以自己造一个) 给它个名字叫 "point.png" 第三步:下载这个图片到 "Graphics\Pictures"。给它个名字叫 "border.png"。大家可以自己造一个,使用自己的 border 必须改变一些变量 (看上方的说明) #============================================================================== # 本脚本来自www.66RPG.com,使用和转载请保留此信息 #============================================================================== #============================================================================== # * Spriteset_MiniMap ver 1.5 #------------------------------------------------------------------------------ # Fanha Giang, 2005/11/18 #==============================================================================
class Spriteset_MiniMap def initialize() @zoom = 0.25 @size = 32 @dsize = @size * @zoom @coner = $game_system.minimap_corner # the viewport for the mini map and the blips @viewport = Viewport.new(0, 0, 640, 480) @viewport.z = 6000
# sprite of minimap @minimap = Sprite_MiniMap.new(@viewport, @dsize)
# bitmap of the minimap @bitmap = Bitmap.new($game_map.width * @dsize, $game_map.height * @dsize) # drawer object @draw_minimap = Draw_MiniBitmap.new(0, @bitmap, 28, 23) @draw_minimap.map_data = $game_map.data @draw_minimap.priorities = $game_map.priorities @draw_minimap.tileset = RPG::Cache.tileset($game_map.tileset_name) for i in 0..6 @draw_minimap.autotiles[i] = RPG::Cache.autotile($game_map.autotile_names[i]) end
# the blips in the map @mini_sprites = [] for event in $game_map.events.values @mini_sprites.push(Sprite_Mini_Character.new(@viewport, @zoom, 1 , event)) end @mini_sprites.push(Sprite_Mini_Character.new(@viewport, @zoom, 0, $game_player))
# viewport of the border and something else addon @bviewport = Viewport.new(0, 0, 640, 480) @bviewport.z = 6001 # init the border @border = Sprite.new(@bviewport) @border.bitmap = RPG::Cache.picture("border")
# init the map name @mapname = Sprite.new(@bviewport) @mapname.x = 30 @mapname.y = 3 @mapname.bitmap = Bitmap.new(200,25) @mapname.bitmap.font.name = "Tahoma" @mapname.bitmap.font.size = 21 @mapname.bitmap.font.color = Color.new(255, 0, 0, 255) @mapname.bitmap.draw_text(@mapname.bitmap.rect, $game_map.name.to_s, 1)
update_viewport update end #-------------------------------------------------------------------------- # - Release #-------------------------------------------------------------------------- def dispose # dispose the bitmap ([email protected]?) ? @bitmap.dispose : nil # dispose the mini map sprite @minimap.dispose # dispose the blips for sprite in @mini_sprites sprite.dispose end # dispose the map name @mapname.bitmap.dispose @mapname.dispose #dispose the border @border.bitmap.dispose @border.dispose # dispose the viewport @viewport.dispose @bviewport.dispose end #-------------------------------------------------------------------------- # - Frame renewal #-------------------------------------------------------------------------- def update # draw the map x1 = (($game_map.display_x - 64) / 128 - 4).to_i y1 = ($game_map.display_y / 128 - 4).to_i @draw_minimap.draw(x1,y1) # update the sprites @minimap.update(@bitmap) for sprite in @mini_sprites sprite.update end
if @coner != $game_system.minimap_corner @coner = $game_system.minimap_corner update_viewport end @viewport.visible = $game_system.minimap_visible @bviewport.visible = $game_system.minimap_visible end #-------------------------------------------------------------------------- def update_viewport width = (640 + @size * 4) * @zoom height = (480 + @size * 4) * @zoom bt = 25 bl = 39 br = 39 bb= 5 case $game_system.minimap_corner when 1 @viewport.rect.set(0 + bl, 0 + bt, width, height) @bviewport.rect.set(0 , 0 , width + bl + br, height + bt + bb) when 2 @viewport.rect.set(640 - width - br, 0 + bt, width, height) @bviewport.rect.set(640 - width - br - bl, 0 , width + bl + br, height + bt + bb) when 3 @viewport.rect.set(0 + bl, 480 - height - bb, width, height) @bviewport.rect.set(0 , 480 - height - bb - bt , width + bl + br, height + bt + bb) when 4 @viewport.rect.set(640 - width - br, 480 - height - bb, width, height) @bviewport.rect.set(640 - width - br - bl , 480 - height - bb - bt , width + bl + br, height + bt + bb) end end #--------------------------------------------------------------------------------------- end
#-------------------------------------------------------------------------- #-------------------------------------------------------------------------- class Game_System attr_accessor :minimap_visible # to set the minimap visible or not attr_accessor :minimap_corner # to set the corner of the minimap 1, 2, 3, 4 alias initialize_minimap initialize def initialize @minimap_visible = false @minimap_corner = 1 initialize_minimap end end #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- class Game_Map # add by the script mini map of Fanha Giang def name text = $map_infos[@map_id].clone text.gsub!(/\\[Nn]\[([0-9]+)\]/) do $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" end return text end # end of the add by Fanha Giang end #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- class Scene_Title # add by the script mini map of Fanha Giang def load_map_infos $map_infos = load_data("Data/MapInfos.rxdata") for key in $map_infos.keys $map_infos[key] = $map_infos[key].name end end # end add end #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- #============================================================================== # * Draw_MiniBitmap ver 1.0 #------------------------------------------------------------------------------ # Fanha Giang, 2005/11/18 #==============================================================================
class Draw_MiniBitmap attr_accessor :tileset attr_accessor :autotiles attr_accessor :map_data attr_accessor :priorities INDEX = [ 26, 27, 32, 33, 4 , 27, 32, 33, 26, 5, 32, 33, 4, 5, 32, 33, 26, 27, 32, 11, 4 , 27, 32, 11, 26, 5, 32, 11, 4, 5, 32, 11, 26, 27, 10, 33, 4 , 27, 10, 33, 26, 5, 10, 33, 4, 5, 10, 33, 26, 27, 10, 11, 4 , 27, 10, 11, 26, 5, 10, 11, 4, 5, 10, 11, 24, 25, 30, 31, 24, 5, 30, 31, 24, 25, 30, 11, 24, 5, 30, 11, 14, 15, 20, 21, 14, 15, 20, 11, 14, 15, 10, 21, 14, 15, 10, 11, 28, 29, 34, 35, 28, 29, 10, 35, 4, 29, 34, 35, 4, 29, 10, 35, 38, 39, 44, 45, 4, 39, 44, 45, 38, 5, 44, 45, 4, 5, 44, 45, 24, 29, 30, 35, 14, 15, 44, 45, 12, 13, 18 ,19, 12, 13, 18, 11, 16, 17, 22, 23, 16, 17, 10, 23, 40, 41, 46, 47, 4, 41, 46, 47, 36, 37, 42, 43, 36, 5, 42, 43, 12, 17, 18, 23, 12, 13, 42, 43, 36, 41, 42, 47, 16, 17, 46, 47, 12, 17, 42, 47, 0, 1, 6, 7 ] X = [0, 1, 0, 1] Y = [0, 0, 1, 1] #-------------------------------------------------------------------------- # ● # type: # 0 : the bitmap size = map.size_X * map.size_Y # 1 : the bitmap size = w * h # 2 : the bitmap size = w * h, and have all the event inside (not in this version) # when you choice type = 0, zoom will fix with 25% # w : width # h : height # zoom : 1 = 25%, 2 = 50%, #-------------------------------------------------------------------------- def initialize(type, bitmap, xsize = 20, ysize = 15, zoom = 1) @type = type @zoom = 0.25 @xsize = xsize @ysize = ysize @zoom *= zoom if type != 0 @bitmap = bitmap @size = 32 @dsize = @size * @zoom @tileset = nil @autotiles = [] @map_data = nil @priorities = nil @map_draw = Table.new(500, 500) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def draw(ox, oy) x1 = (ox < 0) ? 0 : ox y1 = (oy < 0) ? 0 : oy x2 = (x1 + @xsize > @map_data.xsize) ? @map_data.xsize : x1 + @xsize y2 = (y1 + @ysize > @map_data.ysize) ? @map_data.ysize : y1 + @ysize
for x in x1...x2 for y in y1...y2 if @map_draw[x,y] == 0 pri_data = check_priorities(x,y) draw_position(x, y, pri_data, 0, 60) @map_draw[x,y] = 1 end end # end for y end # end for x end #--------------------------------------------------------------------------------------- # check to be sure that the low priorities Tile is draw frist #--------------------------------------------------------------------------------------- def check_priorities(x,y) # hash { priorities--> tile_pos } myhash = {} for i in [0,1,2] # position of the tile in Tiles tile_pos = @map_data[x,y,i] # get the priorities for the tile priorities = @priorities[tile_pos] myhash[priorities * 10 + i] = tile_pos end return myhash.sort end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def draw_position(x, y, pri_data, low, high) for layer in [0,1,2] priorities = pri_data[layer][0] if priorities< low or priorities >= high next layer end pos = pri_data[layer][1] #if it is tile if pos >= 384 pos -= 384 yy = pos / 8 xx = pos % 8 src_rect = Rect.new(xx * @size, yy * @size , @size, @size ) des_rect = Rect.new(x * @dsize, y * @dsize, @dsize , @dsize ) @bitmap.stretch_blt(des_rect , @tileset, src_rect) next layer end # if it is autotile if pos >= 48 and pos < 384 # get autotiles position id = pos / 48 - 1 pos = pos % 48 for corner in [0,1,2,3] h = 4 * pos + corner yy = INDEX[h] / 6 xx = INDEX[h] % 6 src_rect = Rect.new(xx * @size / 2 , yy * @size / 2 , @size / 2 , @size / 2 ) des_rect = Rect.new(x * @dsize + X[corner] * @dsize / 2, y * @dsize + Y[corner] * @dsize / 2 , @dsize / 2, @dsize / 2 ) @bitmap.stretch_blt(des_rect , @autotiles[id], src_rect) end # end for corner end # end of if pos >= 48 and pos < 384 end # end for i end #-------------------------------------------------------------------------- end #============================================================================== # * Sprite_MiniMap ver 1.0 #------------------------------------------------------------------------------ # Written by Fanha Giang, [email protected] # ==> You can delete all my comments except the copyright and creator info. Thanks. #============================================================================== #==============================================================================
class Sprite_MiniMap < Sprite #-------------------------------------------------------------------------- # - Object initialization #-------------------------------------------------------------------------- def initialize(viewport, dsize) super(viewport) self.x = 0 self.y = 0 self.z = 0 self.opacity = 255 @dsize = dsize end #-------------------------------------------------------------------------- # - Update view #-------------------------------------------------------------------------- def update(bitmap) self.bitmap = bitmap sy = $game_map.display_y * @dsize / 128 sx = $game_map.display_x * @dsize / 128 self.src_rect.set(sx - @dsize * 2 , sy - @dsize * 2, (20 + 4) * @dsize, (480 + 4) * @dsize ) #self.src_rect.set(sx , sy , 640 * @dsize, 480 * @dsize) end #--------------------------------------------------------------------------------------- end #============================================================================== # * Sprite_Mini_Character ver 1.0 #------------------------------------------------------------------------------ # Develop from Sprite_Characterby Fanha Giang, [email protected] # ==> You can delete all my comments except the copyright and creator info. Thanks. #==============================================================================
class Sprite_Mini_Character < RPG::Sprite #-------------------------------------------------------------------------- # - Open instance variable #-------------------------------------------------------------------------- attr_accessor :character # Character #-------------------------------------------------------------------------- # - Object initialization # viewport : View port # zoom : zoom of the mini map # type : type of event. 0 = enemy, 1 = allied, 2 = player, 3 = events point # character : Character (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, zoom, type ,character = nil) super(viewport) @character = character @zoom = zoom @type = type
self.bitmap = RPG::Cache.character("point", 0) @cw = self.bitmap.width / 4 @ch = self.bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch update end #-------------------------------------------------------------------------- # - Frame renewal #-------------------------------------------------------------------------- def update super if @type > 0 if (@character.list == nil) or (@character.character_name == "") self.visible = false return end
@type = -1 for i in [email protected] if @character.list[i].parameters[0].is_a?(String) if @character.list[i].parameters[0] == "event" @type = 4 break elsif @character.list[i].parameters[0] == "savepoint" @type = 5 break elsif @character.list[i].parameters[0] == "teleport" @type = 6 break elsif @character.list[i].parameters[0] == "chest" @type = 7 break elsif @character.list[i].parameters[0] == "enemy" @type = 1 break elsif @character.list[i].parameters[0] == "allied" @type = 2 break end end end end # Setting visible state self.visible = (not @character.transparent) # When graphics is not the character if @type >= 4 sx = 3 * @cw sy = (@type % 4) * @ch else sx = @type * @cw sy = (@character.direction - 2) / 2 * @ch end self.src_rect.set(sx, sy, @cw, @ch) # Setting the coordinate of sprite #sy = $game_map.display_y * 32 / 128 #sx = $game_map.display_x * 32 / 128 sx = 0 sy = 0 #self.x = (sx + @character.screen_x) * @zoom #self.y = (sy + @character.screen_y) * @zoom self.x = (sx + @character.screen_x + 32 * 2) * @zoom self.y = (sy + @character.screen_y + 32 * 2) * @zoom self.z = 10 - @type end end #============================================================================== # 本脚本来自www.66RPG.com,使用和转载请保留此信息 #============================================================================== 第四步:在 Scene_Title 在 main 里面, 在 $data_system = load_data("Data/System.rxdata") 下面添加 # load the map infos need for the mini map script by Fanha Giang load_map_infos 第五步:在 Scene_Map 在 main 里面, 在 @spriteset = Spriteset_Map.new 下面 +++++
#draw the mini map @mini_zoom = 25.0/100.0 @minimap = Spriteset_MiniMap.new(@mini_zoom)
在 main 里面, 在 @spriteset.dispose 下面 +++++
# Releasing Mini Map @minimap.dispose
在 update 里面,在 @spriteset.update 下面 +++++
# Renewing mini map sprite set @minimap.update
在 transfer_player 里面, 在 @spriteset = Spriteset_Map.new 下面添加 @minimap.dispose @minimap = Spriteset_MiniMap.new(@mini_zoom) |