设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2993|回复: 1
打印 上一主题 下一主题

[已经解决] 如何在游戏画面上显小地图?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
45
在线时间
42 小时
注册时间
2012-8-10
帖子
83
跳转到指定楼层
1
 楼主| 发表于 2013-3-9 21:43:28 手机端发表。 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 769429500 于 2013-3-15 22:44 编辑

如题。
要显示主角所在位置的。

Lv1.梦旅人

梦石
0
星屑
50
在线时间
67 小时
注册时间
2013-2-1
帖子
25
2
发表于 2013-3-10 11:06:14 | 只看该作者
本帖最后由 protosssonny 于 2013-3-10 11:52 编辑

RUBY 代码复制
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 迷你地图显示 ◆ VX ◆
  3. #_/    ◇ Last update : 2009/09/13 ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/  新增的迷你地图显示功能。很好的地图通行度检查工具
  6. #
  7. #    设定开关使用迷你地图显示,默认1号开关
  8. #    事件名字+空格+[OBJ1],显示绿点,颜色45句更改
  9. #    事件名字+空格+[OBJ2],显示蓝点,颜色46句更改
  10. #    事件名字+空格+[OBJ3], 显示品红点,颜色47句更改
  11. #   
  12. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  13.  
  14. #==============================================================================
  15. # ★ 自定义项 - Customize ★
  16. #==============================================================================
  17.  
  18. module KGC
  19. module MiniMap
  20.   # ◆ 迷你地图显示ON / OFF开关来切换的ID
  21.   MINIMAP_SWITCH_ID = 14
  22.  
  23.   # ◆ 大小的迷你地图显示位置(X,y,宽度,高度)
  24.   MAP_RECT = Rect.new(800-160-10, 10, 160, 120)
  25.   # ◆ Z坐标的迷你地图
  26.   MAP_Z = 0
  27.   # ◆ 一平方米大小​​的
  28.   #  三个或更多的建议。
  29.   GRID_SIZE = 5
  30.  
  31.   # ◆ 小地图前景色(通行可)
  32.   FOREGROUND_COLOR = Color.new(224, 224, 255, 40)
  33.   # ◆ 小地图背景色(通行不可)
  34.   BACKGROUND_COLOR = Color.new(0, 0, 0, 100)
  35.   #BACKGROUND_COLOR = Color.new(0, 0, 160, 160)
  36.  
  37.   # ◆ 現在位置图标色
  38.   POSITION_COLOR   = Color.new(255, 0, 0, 192)
  39.   # ◆ 地图移动事件[移动]颜色
  40.   MOVE_EVENT_COLOR = Color.new(255, 160, 0, 192)
  41.  
  42.   # ◆ 物体颜色
  43.   #  从元素的开始[OBJ1],[obj2的],...的支持。
  44.   OBJECT_COLOR = [
  45.     Color.new(  0, 160,   0, 192),  # [OBJ 1]
  46.     Color.new(  0, 160, 255, 192),  # [OBJ 2]
  47.     Color.new(160,   0, 160, 192),  # [OBJ 3]
  48.   ]  # ← 这]无法抹去!
  49.  
  50.   # ◆ 图标的实力闪烁
  51.   #  约5至8建议。
  52.   BLINK_LEVEL = 8  # 0不闪烁 5-8闪烁
  53.  
  54.   # ◆ 现金地图
  55.   #  超过这个数字并不指从很长一段时间删除这些。
  56.   CACHE_NUM = 10
  57. end
  58. end
  59.  
  60. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  61.  
  62. $imported = {} if $imported == nil
  63. $imported["MiniMap"] = true
  64.  
  65. if $data_mapinfos == nil
  66.   $data_mapinfos = load_data("Data/MapInfos.rvdata")
  67. end
  68.  
  69. module KGC::MiniMap
  70.   module Regexp
  71.     # ミニマップ非表示
  72.     NO_MINIMAP = /\[NOMAP\]/i
  73.     # 障害物
  74.     WALL_EVENT = /\[WALL\]/i
  75.     # 移動イベント
  76.     MOVE_EVENT = /\[MOVE\]/i
  77.     # オブジェクト
  78.     OBJECT = /\[OBJ(?:ECT)?\s*(\d)\]/i
  79.   end
  80. end
  81.  
  82. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  83.  
  84. #==============================================================================
  85. # □ KGC::Commands
  86. #==============================================================================
  87.  
  88. module KGC
  89. module Commands
  90.   module_function
  91.   #--------------------------------------------------------------------------
  92.   # ○ ミニマップを表示
  93.   #--------------------------------------------------------------------------
  94.   def show_minimap
  95.     $game_system.minimap_show = true
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ○ ミニマップを隠す
  99.   #--------------------------------------------------------------------------
  100.   def hide_minimap
  101.     $game_system.minimap_show = false
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ○ ミニマップをリフレッシュ
  105.   #--------------------------------------------------------------------------
  106.   def refresh_minimap
  107.     return unless $scene.is_a?(Scene_Map)
  108.  
  109.     $game_map.refresh if $game_map.need_refresh
  110.     $scene.refresh_minimap
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ○ ミニマップのオブジェクトを更新
  114.   #--------------------------------------------------------------------------
  115.   def update_minimap_object
  116.     return unless $scene.is_a?(Scene_Map)
  117.  
  118.     $game_map.refresh if $game_map.need_refresh
  119.     $scene.update_minimap_object
  120.   end
  121. end
  122. end
  123.  
  124. class Game_Interpreter
  125.   include KGC::Commands
  126. end
  127.  
  128. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  129.  
  130. #==============================================================================
  131. # ■ RPG::MapInfo
  132. #==============================================================================
  133.  
  134. class RPG::MapInfo
  135.   #--------------------------------------------------------------------------
  136.   # ● マップ名取得
  137.   #--------------------------------------------------------------------------
  138.   def name
  139.     return @name.gsub(/\[.*\]/) { "" }
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ○ オリジナルマップ名取得
  143.   #--------------------------------------------------------------------------
  144.   def original_name
  145.     return @name
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ○ ミニマップのキャッシュ生成
  149.   #--------------------------------------------------------------------------
  150.   def create_minimap_cache
  151.     @__minimap_show = !(@name =~ KGC::MiniMap::Regexp::NO_MINIMAP)
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ○ ミニマップ表示
  155.   #--------------------------------------------------------------------------
  156.   def minimap_show?
  157.     create_minimap_cache if @__minimap_show == nil
  158.     return @__minimap_show
  159.   end
  160. end
  161.  
  162. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  163.  
  164. #==============================================================================
  165. # ■ Game_System
  166. #==============================================================================
  167.  
  168. class Game_System
  169.   #--------------------------------------------------------------------------
  170.   # ○ ミニマップ表示フラグ取得
  171.   #--------------------------------------------------------------------------
  172.   def minimap_show
  173.     return $game_switches[KGC::MiniMap::MINIMAP_SWITCH_ID]
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ○ ミニマップ表示フラグ変更
  177.   #--------------------------------------------------------------------------
  178.   def minimap_show=(value)
  179.     $game_switches[KGC::MiniMap::MINIMAP_SWITCH_ID] = value
  180.     $game_map.need_refresh = true
  181.   end
  182. end
  183.  
  184. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  185.  
  186. #==============================================================================
  187. # ■ Game_Map
  188. #==============================================================================
  189.  
  190. class Game_Map
  191.   #--------------------------------------------------------------------------
  192.   # ○ ミニマップを表示するか
  193.   #--------------------------------------------------------------------------
  194.   def minimap_show?
  195.     return $data_mapinfos[map_id].minimap_show?
  196.   end
  197. end
  198.  
  199. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  200.  
  201. #==============================================================================
  202. # ■ Game_Event
  203. #==============================================================================
  204.  
  205. class Game_Event < Game_Character
  206.   #--------------------------------------------------------------------------
  207.   # ○ グラフィックがあるか
  208.   #--------------------------------------------------------------------------
  209.   def graphic_exist?
  210.     return (character_name != "" || tile_id > 0)
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ○ 障害物か
  214.   #--------------------------------------------------------------------------
  215.   def is_minimap_wall_event?
  216.     return (@event.name =~ KGC::MiniMap::Regexp::WALL_EVENT)
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ○ 移動イベントか
  220.   #--------------------------------------------------------------------------
  221.   def is_minimap_move_event?
  222.     return (@event.name =~ KGC::MiniMap::Regexp::MOVE_EVENT)
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ○ ミニマップオブジェクトか
  226.   #--------------------------------------------------------------------------
  227.   def is_minimap_object?
  228.     return (@event.name =~ KGC::MiniMap::Regexp::OBJECT)
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ○ ミニマップオブジェクトタイプ
  232.   #--------------------------------------------------------------------------
  233.   def minimap_object_type
  234.     if @event.name =~ KGC::MiniMap::Regexp::OBJECT
  235.       return $1.to_i
  236.     else
  237.       return 0
  238.     end
  239.   end
  240. end
  241.  
  242. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  243.  
  244. #==============================================================================
  245. # □ Game_MiniMap
  246. #------------------------------------------------------------------------------
  247. #   ミニマップを扱うクラスです。
  248. #==============================================================================
  249.  
  250. class Game_MiniMap
  251.   #--------------------------------------------------------------------------
  252.   # ○ 構造体
  253.   #--------------------------------------------------------------------------
  254.   Point = Struct.new(:x, :y)
  255.   Size  = Struct.new(:width, :height)
  256.   PassageCache = Struct.new(:map_id, :table, :scan_table)
  257.   #--------------------------------------------------------------------------
  258.   # ○ クラス変数
  259.   #--------------------------------------------------------------------------
  260.   @@passage_cache = []  # 通行フラグテーブルキャッシュ
  261.   #--------------------------------------------------------------------------
  262.   # ● オブジェクト初期化
  263.   #--------------------------------------------------------------------------
  264.   def initialize(tilemap)
  265.     @map_rect  = KGC::MiniMap::MAP_RECT
  266.     @grid_size = [KGC::MiniMap::GRID_SIZE, 1].max
  267.  
  268.     @x = 0
  269.     @y = 0
  270.     @grid_num = Point.new(
  271.       (@map_rect.width  + @grid_size - 1) / @grid_size,
  272.       (@map_rect.height + @grid_size - 1) / @grid_size
  273.     )
  274.     @draw_grid_num    = Point.new(@grid_num.x + 2, @grid_num.y + 2)
  275.     @draw_range_begin = Point.new(0, 0)
  276.     @draw_range_end   = Point.new(0, 0)
  277.     @tilemap = tilemap
  278.  
  279.     @last_x = $game_player.x
  280.     @last_y = $game_player.y
  281.  
  282.     create_sprites
  283.     refresh
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ○ スプライト作成
  287.   #--------------------------------------------------------------------------
  288.   def create_sprites
  289.     @viewport   = Viewport.new(@map_rect)
  290.     @viewport.z = KGC::MiniMap::MAP_Z
  291.  
  292.     # ビットマップサイズ計算
  293.     @bmp_size = Size.new(
  294.       (@grid_num.x + 2) * @grid_size,
  295.       (@grid_num.y + 2) * @grid_size
  296.     )
  297.     @buf_bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
  298.  
  299.     # マップ用スプライト作成
  300.     @map_sprite   = Sprite.new(@viewport)
  301.     @map_sprite.x = -@grid_size
  302.     @map_sprite.y = -@grid_size
  303.     @map_sprite.z = 0
  304.     @map_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
  305.  
  306.     # オブジェクト用スプライト作成
  307.     @object_sprite   = Sprite_MiniMapIcon.new(@viewport)
  308.     @object_sprite.x = -@grid_size
  309.     @object_sprite.y = -@grid_size
  310.     @object_sprite.z = 1
  311.     @object_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)
  312.  
  313.     # 現在位置スプライト作成
  314.     @position_sprite   = Sprite_MiniMapIcon.new
  315.     @position_sprite.x = @map_rect.x + @grid_num.x / 2 * @grid_size
  316.     @position_sprite.y = @map_rect.y + @grid_num.y / 2 * @grid_size
  317.     @position_sprite.z = @viewport.z + 2
  318.     bitmap = Bitmap.new(@grid_size, @grid_size)
  319.     bitmap.fill_rect(bitmap.rect, KGC::MiniMap::POSITION_COLOR)
  320.     @position_sprite.bitmap = bitmap
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 解放
  324.   #--------------------------------------------------------------------------
  325.   def dispose
  326.     @buf_bitmap.dispose
  327.     @map_sprite.bitmap.dispose
  328.     @map_sprite.dispose
  329.     @object_sprite.bitmap.dispose
  330.     @object_sprite.dispose
  331.     @position_sprite.bitmap.dispose
  332.     @position_sprite.dispose
  333.     @viewport.dispose
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ○ 可視状態取得
  337.   #--------------------------------------------------------------------------
  338.   def visible
  339.     return @map_sprite.visible
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ○ 可視状態設定
  343.   #--------------------------------------------------------------------------
  344.   def visible=(value)
  345.     @viewport.visible        = value
  346.     @map_sprite.visible      = value
  347.     @object_sprite.visible   = value
  348.     @position_sprite.visible = value
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ○ リフレッシュ
  352.   #--------------------------------------------------------------------------
  353.   def refresh
  354.     update_draw_range
  355.     update_passage_table
  356.     update_object_list
  357.     update_position
  358.     draw_map
  359.     draw_object
  360.     Graphics.frame_reset
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ○ 描画範囲更新
  364.   #--------------------------------------------------------------------------
  365.   def update_draw_range
  366.     range = []
  367.     (2).times { |i| range[i] = @draw_grid_num[i] / 2 }
  368.  
  369.     @draw_range_begin.x = $game_player.x - range[0]
  370.     @draw_range_begin.y = $game_player.y - range[1]
  371.     @draw_range_end.x   = $game_player.x + range[0]
  372.     @draw_range_end.y   = $game_player.y + range[1]
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ○ 通行可否テーブル更新
  376.   #--------------------------------------------------------------------------
  377.   def update_passage_table
  378.     cache = get_passage_table_cache
  379.     @passage_table      = cache.table
  380.     @passage_scan_table = cache.scan_table
  381.  
  382.     update_around_passage
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ○ 通行可否テーブルのキャッシュを取得
  386.   #--------------------------------------------------------------------------
  387.   def get_passage_table_cache
  388.     map_id = $game_map.map_id
  389.     cache  = @@passage_cache.find { |c| c.map_id == map_id }
  390.     if cache == nil
  391.       # キャッシュミス
  392.       cache = PassageCache.new(map_id)
  393.       cache.table      = Table.new($game_map.width, $game_map.height)
  394.       cache.scan_table = Table.new(
  395.         ($game_map.width  + @draw_grid_num.x - 1) / @draw_grid_num.x,
  396.         ($game_map.height + @draw_grid_num.y - 1) / @draw_grid_num.y
  397.       )
  398.     end
  399.  
  400.     # 直近のキャッシュは先頭、古いキャッシュは削除
  401.     @@passage_cache.unshift(cache)
  402.     @@passage_cache.delete_at(KGC::MiniMap::CACHE_NUM)
  403.  
  404.     return cache
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # ○ 通行可否テーブルのキャッシュをクリア
  408.   #--------------------------------------------------------------------------
  409.   def clear_passage_table_cache
  410.     return if @passage_scan_table == nil
  411.  
  412.     table = @passage_scan_table
  413.     @passage_scan_table = Table.new(table.xsize, table.ysize)
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ○ 通行可否テーブルの探索
  417.   #     x, y : 探索位置
  418.   #--------------------------------------------------------------------------
  419.   def scan_passage(x, y)
  420.     dx = x / @draw_grid_num.x
  421.     dy = y / @draw_grid_num.y
  422.  
  423.     return if @passage_scan_table[dx, dy] == 1
  424.     return unless dx.between?(0, @passage_scan_table.xsize - 1)
  425.     return unless dy.between?(0, @passage_scan_table.ysize - 1)
  426.  
  427.     rx = (dx * @draw_grid_num.x)...((dx + 1) * @draw_grid_num.x)
  428.     ry = (dy * @draw_grid_num.y)...((dy + 1) * @draw_grid_num.y)
  429.     mw = $game_map.width  - 1
  430.     mh = $game_map.height - 1
  431.     rx.each { |x|
  432.       next unless x.between?(0, mw)
  433.       ry.each { |y|
  434.         next unless y.between?(0, mh)
  435.         @passage_table[x, y] = ($game_map.passable?(x, y) ? 1 : 0)
  436.       }
  437.     }
  438.     @passage_scan_table[dx, dy] = 1
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ○ 周辺の通行可否テーブル更新
  442.   #--------------------------------------------------------------------------
  443.   def update_around_passage
  444.     gx = @draw_grid_num.x
  445.     gy = @draw_grid_num.y
  446.     dx = $game_player.x - gx / 2
  447.     dy = $game_player.y - gy / 2
  448.     scan_passage(dx,      dy)
  449.     scan_passage(dx + gx, dy)
  450.     scan_passage(dx,      dy + gy)
  451.     scan_passage(dx + gx, dy + gy)
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ○ オブジェクト一覧更新
  455.   #--------------------------------------------------------------------------
  456.   def update_object_list
  457.     events = $game_map.events.values
  458.  
  459.     # WALL
  460.     @wall_events = events.find_all { |e|
  461.       e.graphic_exist? && e.is_minimap_wall_event?
  462.     }
  463.  
  464.     # MOVE
  465.     @move_events = events.find_all { |e|
  466.       e.graphic_exist? && e.is_minimap_move_event?
  467.     }
  468.  
  469.     # OBJ
  470.     @object_list = []
  471.     events.each { |e|
  472.       next unless e.graphic_exist?
  473.       next unless e.is_minimap_object?
  474.  
  475.       type = e.minimap_object_type
  476.       if @object_list[type] == nil
  477.         @object_list[type] = []
  478.       end
  479.       @object_list[type] << e
  480.     }
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # ○ 位置更新
  484.   #--------------------------------------------------------------------------
  485.   def update_position
  486.     pt = Point.new($game_player.x, $game_player.y)
  487.     dx = ($game_player.real_x - pt.x * 256) * @grid_size / 256
  488.     dy = ($game_player.real_y - pt.y * 256) * @grid_size / 256
  489.     ox = dx % @grid_size
  490.     oy = dy % @grid_size
  491.     ox = -(@grid_size - ox) if dx < 0
  492.     oy = -(@grid_size - oy) if dy < 0
  493.     @viewport.ox = ox
  494.     @viewport.oy = oy
  495.     if pt.x != @last_x || pt.y != @last_y
  496.       draw_map
  497.       @last_x = pt.x
  498.       @last_y = pt.y
  499.     end
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ○ 描画範囲内判定
  503.   #--------------------------------------------------------------------------
  504.   def in_draw_range?(x, y)
  505.     rb = @draw_range_begin
  506.     re = @draw_range_end
  507.     return (x.between?(rb.x, re.x) && y.between?(rb.y, re.y))
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ○ マップ範囲内判定
  511.   #--------------------------------------------------------------------------
  512.   def in_map_range?(x, y)
  513.     mw = $game_map.width
  514.     mh = $game_map.height
  515.     return (x.between?(0, mw - 1) && y.between?(0, mh - 1))
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ○ マップ描画
  519.   #     dir : 追加位置 (0 で全体)
  520.   #--------------------------------------------------------------------------
  521.   def draw_map(dir = 0)
  522.     bitmap  = @map_sprite.bitmap
  523.     bitmap.fill_rect(bitmap.rect, KGC::MiniMap::BACKGROUND_COLOR)
  524.  
  525.     rect = Rect.new(0, 0, @grid_size, @grid_size)
  526.  
  527.     range_x = (@draw_range_begin.x)..(@draw_range_end.x)
  528.     range_y = (@draw_range_begin.y)..(@draw_range_end.y)
  529.     mw = $game_map.width  - 1
  530.     mh = $game_map.height - 1
  531.     update_around_passage
  532.  
  533.     # 通行可能領域描画
  534.     range_x.each { |x|
  535.       next unless x.between?(0, mw)
  536.       range_y.each { |y|
  537.         next unless y.between?(0, mh)
  538.         next if @passage_table[x, y] == 0
  539.         next if @wall_events.find { |e| e.x == x && e.y == y }  # 壁
  540.  
  541.         rect.x = (x - @draw_range_begin.x) * @grid_size
  542.         rect.y = (y - @draw_range_begin.y) * @grid_size
  543.         bitmap.fill_rect(rect, KGC::MiniMap::FOREGROUND_COLOR)
  544.       }
  545.     }
  546.  
  547.     # MOVE
  548.     @move_events.each { |e|
  549.       rect.x = (e.x - @draw_range_begin.x) * @grid_size
  550.       rect.y = (e.y - @draw_range_begin.y) * @grid_size
  551.       bitmap.fill_rect(rect, KGC::MiniMap::MOVE_EVENT_COLOR)
  552.     }
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ○ オブジェクト描画
  556.   #--------------------------------------------------------------------------
  557.   def draw_object
  558.     # 下準備
  559.     bitmap = @object_sprite.bitmap
  560.     bitmap.clear
  561.     rect = Rect.new(0, 0, @grid_size, @grid_size)
  562.  
  563.     # オブジェクト描画
  564.     @object_list.each_with_index { |list, i|
  565.       color = KGC::MiniMap::OBJECT_COLOR[i - 1]
  566.       next if list.nil? || color.nil?
  567.  
  568.       list.each { |obj|
  569.         next unless in_draw_range?(obj.x, obj.y)
  570.  
  571.         rect.x = (obj.real_x - @draw_range_begin.x * 256) * @grid_size / 256
  572.         rect.y = (obj.real_y - @draw_range_begin.y * 256) * @grid_size / 256
  573.         bitmap.fill_rect(rect, color)
  574.       }
  575.     }
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # ○ 更新
  579.   #--------------------------------------------------------------------------
  580.   def update
  581.     return unless @map_sprite.visible
  582.  
  583.     update_draw_range
  584.     update_position
  585.     draw_object
  586.     @map_sprite.update
  587.     @object_sprite.update
  588.     @position_sprite.update
  589.   end
  590. end
  591.  
  592. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  593.  
  594. #==============================================================================
  595. # □ Sprite_MiniMapIcon
  596. #------------------------------------------------------------------------------
  597. #   ミニマップ用アイコンのクラスです。
  598. #==============================================================================
  599.  
  600. class Sprite_MiniMapIcon < Sprite
  601.   DURATION_MAX = 60
  602.   #--------------------------------------------------------------------------
  603.   # ● オブジェクト初期化
  604.   #     viewport : ビューポート
  605.   #--------------------------------------------------------------------------
  606.   def initialize(viewport = nil)
  607.     super(viewport)
  608.     @duration = DURATION_MAX / 2
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● フレーム更新
  612.   #--------------------------------------------------------------------------
  613.   def update
  614.     super
  615.     @duration += 1
  616.     if @duration == DURATION_MAX
  617.       @duration = 0
  618.     end
  619.     update_effect
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ○ エフェクトの更新
  623.   #--------------------------------------------------------------------------
  624.   def update_effect
  625.     self.color.set(255, 255, 255,
  626.       (@duration - DURATION_MAX / 2).abs * KGC::MiniMap::BLINK_LEVEL
  627.     )
  628.   end
  629. end
  630.  
  631. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  632.  
  633. #==============================================================================
  634. # ■ Spriteset_Map
  635. #==============================================================================
  636.  
  637. class Spriteset_Map
  638.   attr_reader :minimap
  639.   #--------------------------------------------------------------------------
  640.   # ● オブジェクト初期化
  641.   #--------------------------------------------------------------------------
  642.   alias initialize_KGC_MiniMap initialize
  643.   def initialize
  644.     initialize_KGC_MiniMap
  645.  
  646.     create_minimap
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ○ ミニマップ作成
  650.   #--------------------------------------------------------------------------
  651.   def create_minimap
  652.     return unless $game_map.minimap_show?
  653.  
  654.     @minimap = Game_MiniMap.new(@tilemap)
  655.     @minimap.visible = $game_system.minimap_show
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 解放
  659.   #--------------------------------------------------------------------------
  660.   alias dispose_KGC_MiniMap dispose
  661.   def dispose
  662.     dispose_KGC_MiniMap
  663.  
  664.     dispose_minimap
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # ○ ミニマップ解放
  668.   #--------------------------------------------------------------------------
  669.   def dispose_minimap
  670.     @minimap.dispose unless @minimap.nil?
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # ● フレーム更新
  674.   #--------------------------------------------------------------------------
  675.   alias update_KGC_MiniMap update
  676.   def update
  677.     update_KGC_MiniMap
  678.  
  679.     update_minimap
  680.   end
  681.   #--------------------------------------------------------------------------
  682.   # ○ ミニマップ更新
  683.   #--------------------------------------------------------------------------
  684.   def update_minimap
  685.     return if @minimap.nil?
  686.  
  687.     if $game_system.minimap_show
  688.       @minimap.visible = true
  689.       @minimap.update
  690.     else
  691.       @minimap.visible = false
  692.     end
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ○ ミニマップ全体をリフレッシュ
  696.   #--------------------------------------------------------------------------
  697.   def refresh_minimap
  698.     return if @minimap.nil?
  699.  
  700.     @minimap.clear_passage_table_cache
  701.     @minimap.refresh
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ○ ミニマップのオブジェクトを更新
  705.   #--------------------------------------------------------------------------
  706.   def update_minimap_object
  707.     @minimap.update_object_list unless @minimap.nil?
  708.   end
  709. end
  710.  
  711. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  712.  
  713. #==============================================================================
  714. # ■ Scene_Map
  715. #==============================================================================
  716.  
  717. class Scene_Map
  718.   #--------------------------------------------------------------------------
  719.   # ○ ミニマップ全体をリフレッシュ
  720.   #--------------------------------------------------------------------------
  721.   def refresh_minimap
  722.     @spriteset.refresh_minimap
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ○ ミニマップのオブジェクトを更新
  726.   #--------------------------------------------------------------------------
  727.   def update_minimap_object
  728.     @spriteset.update_minimap_object
  729.   end
  730. end

点评

分辨率 改一下就可以用了  发表于 2013-3-10 11:06
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-7 09:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表