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

Project1

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

显示地图通行度

[复制链接]

…あたしは天使なんかじゃないわ

梦石
0
星屑
2207
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

跳转到指定楼层
1
发表于 2014-6-14 18:37:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 taroxd 于 2015-2-18 12:50 编辑

RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2. # ● require Taroxd基础设置,修复bug
  3. #    使用方法:游戏测试中按下F6即可启用,再按一次关闭
  4. #--------------------------------------------------------------------------
  5.  
  6. class Taroxd::PlanePassage < Plane
  7.  
  8.   ENABLE = $TEST                       # 是否启用功能
  9.   KEY = :F6                            # 控制显示通行度的按键
  10.   VISIBLE = false                      # 起始时是否可见
  11.   OPACITY = 150                        # 不透明度
  12.   NG = Color.new(255, 0, 0, OPACITY)   # 不可通行的颜色
  13.   OK = Color.new(0, 0, 255, OPACITY)   # 可以通行的颜色
  14.   NG_WIDTH = 4                         # 不可通行方向显示的宽度
  15.  
  16.   include Taroxd::DisposeBitmap
  17.   include Taroxd::BugFix::PlaneVisible
  18.  
  19.   def initialize(_)
  20.     super
  21.     self.visible = VISIBLE
  22.     self.z = 200
  23.     refresh
  24.     update
  25.   end
  26.  
  27.   def update
  28.     self.visible ^= true if Input.trigger?(KEY)
  29.     self.ox = $game_map.display_x * 32
  30.     self.oy = $game_map.display_y * 32
  31.   end
  32.  
  33.   def refresh
  34.     bitmap.dispose if bitmap
  35.     self.bitmap = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  36.     $game_map.width.times do |x|
  37.       $game_map.height.times do |y|
  38.         draw_point(x, y)
  39.       end
  40.     end
  41.   end
  42.  
  43.   # 绘制地图上的点 (x, y)
  44.   def draw_point(x, y)
  45.     ng_dirs = [2, 4, 6, 8].reject { |d| $game_map.passable?(x, y, d) }
  46.     if ng_dirs.size == 4
  47.       bitmap.fill_rect(x * 32, y * 32, 32, 32, NG)
  48.       return
  49.     end
  50.     bitmap.fill_rect(x * 32, y * 32, 32, 32, OK)
  51.     ng_dirs.each do |d|
  52.       dx = d == 6 ? 32 - NG_WIDTH : 0
  53.       dy = d == 2 ? 32 - NG_WIDTH : 0
  54.       if d == 2 || d == 8
  55.         width  = 32
  56.         height = NG_WIDTH
  57.       else
  58.         width  = NG_WIDTH
  59.         height = 32
  60.       end
  61.       bitmap.fill_rect(x * 32 + dx, y * 32 + dy, width, height, NG)
  62.     end
  63.   end
  64. end
  65.  
  66. class Spriteset_Map
  67.   def_before :create_parallax do
  68.     @passage_plane = Taroxd::PlanePassage.new(@viewport3)
  69.   end
  70.   def_before(:update_parallax)    { @passage_plane.update  }
  71.   def_before(:refresh_characters) { @passage_plane.refresh }
  72.   def_before(:dispose_parallax)   { @passage_plane.dispose }
  73. end if Taroxd::PlanePassage::ENABLE
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-4-28 12:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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