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

Project1

 找回密码
 注册会员
搜索
查看: 3076|回复: 3

[已经解决] 如何做到在地图左上角显示雷达?(小地图)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2015-12-23
帖子
22
发表于 2016-1-31 18:16:51 | 显示全部楼层 |阅读模式

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

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

x
如下图,怎么用RPG XP做到这种效果?求解答!(表示搜索过没有用,求范例)

这种效果

这种效果

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

发表于 2016-1-31 18:30:16 | 显示全部楼层
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4.  
  5. #==============================================================================
  6. # ■ 縮小地图的表示(ver 0.999)
  7. # by ピニョン clum-sea
  8. #==============================================================================
  9. #==============================================================================
  10. # □ 前期定义
  11. #==============================================================================
  12. module PLAN_Map_Window
  13.   WIN_X       = 1         # 地图的 X 座標
  14.   WIN_Y       = 1         # 地图的 Y 座標
  15.   WIN_WIDTH   = 6*32      # 地图的宽度
  16.   WIN_HEIGHT  = 4*32      # 地图的高度
  17.   ZOOM        = 8.0       # 地图的放缩比例
  18.   WINDOWSKIN  = "11.png"        # 自定义地图窗口素材,如果留空则是默认的
  19.  
  20.   ON_OFF_KEY  = Input::X  # 打开地图的按钮,X就是键盘的A键
  21.  
  22.   SWITCH      = 7       # 禁用地图功能的开关,默认这个就是打开100号开关则禁止
  23.                           # 使用地图功能,关闭则可以使用地图功能
  24.  
  25.   WINDOW_MOVE = true      # 窗口中的地图跟随移动,(true:跟随, false:固定)
  26.  
  27.   OVER_X      = 632 - WIN_WIDTH   # 移動后的 X 座標(初期位置と往復します)
  28.   OVER_Y      = 8         # 移動后的 Y 座標(初期位置と往復します)
  29.  
  30.   OPACITY     = 192       # 窗口的透明度
  31.   C_OPACITY   = 192       # 地图的透明度
  32.   VISIBLE     = false      # 最初是否可见
  33. end
  34. #==============================================================================
  35. # ■ Game_Temp
  36. #==============================================================================
  37. class Game_Temp
  38.   attr_accessor  :map_visible     # 地图的表示状態
  39.   alias plan_map_window_initialize initialize
  40.   def initialize
  41.     plan_map_window_initialize
  42.     @map_visible = false
  43.   end
  44. end
  45. #==============================================================================
  46. # ■ Scene_Map
  47. #==============================================================================
  48. class Scene_Map
  49.   #--------------------------------------------------------------------------
  50.   # ● 主处理
  51.   #--------------------------------------------------------------------------
  52.   alias plan_map_window_main main
  53.   def main
  54.     @map_window         = Window_Map.new
  55.     @map_window.visible = $game_temp.map_visible
  56.     plan_map_window_main
  57.     @map_window.dispose
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 更新
  61.   #--------------------------------------------------------------------------
  62.   alias plan_map_window_update update
  63.   def update
  64.     $game_temp.map_visible = @map_window.visible
  65.     plan_map_window_update
  66.     unless $game_switches[PLAN_Map_Window::SWITCH]      
  67.       if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
  68.         if @map_window.visible
  69.           @map_window.visible = false
  70.         else
  71.           @map_window.visible = true
  72.         end
  73.       end
  74.     else
  75.       if @map_window.visible
  76.         @map_window.visible = false
  77.       end
  78.     end
  79.     if @map_window.visible
  80.       @map_window.update
  81.     end
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 场所移动的变化
  85.   #--------------------------------------------------------------------------
  86.   alias plan_map_window_transfer_player transfer_player
  87.   def transfer_player
  88.     visible = @map_window.visible
  89.     @map_window.visible = false
  90.     plan_map_window_transfer_player
  91.     @map_window.dispose
  92.     @map_window = Window_Map.new
  93.     @map_window.visible = visible
  94.   end
  95. end
  96. #==============================================================================
  97. # ■ Window_Map
  98. #==============================================================================
  99. class Window_Map < Window_Base
  100.   #--------------------------------------------------------------------------
  101.   # ● 初始化
  102.   #--------------------------------------------------------------------------
  103.   def initialize
  104.     x = PLAN_Map_Window::WIN_X
  105.     y = PLAN_Map_Window::WIN_Y
  106.     w = PLAN_Map_Window::WIN_WIDTH
  107.     h = PLAN_Map_Window::WIN_HEIGHT
  108.     super(x, y, w, h)
  109.     unless PLAN_Map_Window::WINDOWSKIN.empty?
  110.       self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)
  111.     end
  112.     self.contents = Bitmap.new(width - 32, height - 32)
  113.     self.opacity = PLAN_Map_Window::OPACITY
  114.     self.contents_opacity = PLAN_Map_Window::C_OPACITY
  115.     @map_data = $game_map.data
  116.     @tileset = RPG::Cache.tileset($game_map.tileset_name)
  117.     @autotiles = []
  118.     for i in 0..6
  119.       autotile_name = $game_map.autotile_names[i]
  120.       @autotiles[i] = RPG::Cache.autotile(autotile_name)
  121.     end
  122.     @old_real_x = $game_player.real_x
  123.     @old_real_y = $game_player.real_y
  124.     @all_map = make_all_map
  125.     self.visible = PLAN_Map_Window::VISIBLE
  126.     refresh
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 缩小图做成
  130.   #--------------------------------------------------------------------------
  131.   def make_all_map
  132.     all_map = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  133.     for y in 0...$game_map.height
  134.       for x in 0...$game_map.width
  135.         for z in 0...3
  136.           tile_num = @map_data[x, y, z]
  137.           next if tile_num == nil
  138.           if tile_num < 384
  139.             if tile_num >= 48
  140.               tile_num -= 48
  141.               src_rect = Rect.new(32, 2 * 32, 32, 32)
  142.               all_map.blt(x * 32, y * 32, @autotiles[tile_num / 48], src_rect)
  143.             end
  144.           else
  145.             tile_num -= 384
  146.             src_rect = Rect.new(tile_num % 8 * 32, tile_num / 8 * 32, 32, 32)
  147.             all_map.blt(x * 32, y * 32, @tileset, src_rect)
  148.           end
  149.         end
  150.       end
  151.     end
  152.     w = ($game_map.width / PLAN_Map_Window::ZOOM) * 32
  153.     h = ($game_map.height / PLAN_Map_Window::ZOOM) * 32
  154.     ret_bitmap = Bitmap.new(w, h)
  155.     src_rect = Rect.new(0, 0, all_map.width, all_map.height)
  156.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  157.     ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
  158.     all_map.dispose
  159.     return ret_bitmap
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 刷新
  163.   #--------------------------------------------------------------------------
  164.   def refresh
  165.     self.contents.clear
  166.     one_tile_size = 32 / PLAN_Map_Window::ZOOM
  167.     x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2
  168.     y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2
  169.     x = x * one_tile_size / 128
  170.     y = y * one_tile_size / 128
  171.     half_width = self.contents.width * 128 / 2
  172.     rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
  173.     rev_x = 0
  174.     if @all_map.width < self.contents.width
  175.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  176.       rev_x -= (self.contents.width - @all_map.width) / 2
  177.       x += rev_x
  178.     elsif half_width > $game_player.real_x * one_tile_size
  179.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  180.       x += rev_x
  181.     elsif half_width > rest_width
  182.       rev_x = -((half_width - rest_width) / 128)
  183.       x += rev_x
  184.     end
  185.     half_height = self.contents.height * 128 / 2
  186.     rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
  187.     rev_y = 0
  188.     if @all_map.height < self.contents.height
  189.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  190.       rev_y -= (self.contents.height - @all_map.height) / 2
  191.       y += rev_y
  192.     elsif half_height > $game_player.real_y * one_tile_size
  193.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  194.       y += rev_y
  195.     elsif half_height > rest_height
  196.       rev_y = -((half_height - rest_height) / 128)
  197.       y += rev_y
  198.     end
  199.     src_rect = Rect.new(x, y, self.contents.width, self.contents.height)
  200.     self.contents.blt(0, 0, @all_map, src_rect)
  201.     if PLAN_Map_Window::WINDOW_MOVE == true
  202.       w = self.x..self.x + self.width
  203.       h = self.y..self.y + self.height
  204.       if w === $game_player.screen_x and h === $game_player.screen_y
  205.         if self.x == PLAN_Map_Window::WIN_X and self.y == PLAN_Map_Window::WIN_Y
  206.           self.x = PLAN_Map_Window::OVER_X
  207.           self.y = PLAN_Map_Window::OVER_Y
  208.         else
  209.           self.x = PLAN_Map_Window::WIN_X
  210.           self.y = PLAN_Map_Window::WIN_Y
  211.         end
  212.       end
  213.     end
  214.     if $game_party.actors.size > 0
  215.       for i in [2, 1, 0]
  216.         tile = @map_data[$game_player.x, $game_player.y, i]
  217.         next if tile == 0
  218.         return if $game_map.priorities[tile] > 0
  219.       end
  220.       actor = $game_party.actors[0]
  221.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  222.       width = bitmap.width / 4
  223.       height = bitmap.height / 4
  224.       src_rect = Rect.new(0, 0, width, height)
  225.       w = width / PLAN_Map_Window::ZOOM
  226.       h = height / PLAN_Map_Window::ZOOM
  227.       x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
  228.       y = self.contents.height / 2 - h / 2 - rev_y
  229.       dest_rect = Rect.new(x, y, w, h)
  230.       self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  231.     end
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 更新
  235.   #--------------------------------------------------------------------------
  236.   def update
  237.     super
  238.     if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y
  239.       @old_real_x = $game_player.real_x
  240.       @old_real_y = $game_player.real_y
  241.       refresh
  242.     end
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 解放
  246.   #--------------------------------------------------------------------------
  247.   def dispose
  248.     super
  249.     @all_map.dispose
  250.   end
  251. end
  252.  
  253. #==============================================================================
  254. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  255. #==============================================================================

点评

显示缺少文件,已用其他素材代替!谢谢!已解决!  发表于 2016-1-31 18:35

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
111
在线时间
17 小时
注册时间
2019-8-3
帖子
5
发表于 2019-8-11 11:39:54 | 显示全部楼层
放在哪,新萌求助
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1422
在线时间
245 小时
注册时间
2019-1-18
帖子
190
发表于 2019-8-11 12:12:02 | 显示全部楼层
显示86行有错误啊,这是怎么回事
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-17 06:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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