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

Project1

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

[已经过期] 空心菱形问题

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

跳转到指定楼层
1
发表于 2013-10-19 18:38:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. #环菱形
  2.     when 4
  3.       delete = []
  4.       p delete
  5.       for i in more_step
  6.         x = position[i][0]
  7.         y = position[i][1]
  8.         # 无视障碍物的场合
  9.         if through
  10.           # 下
  11.           if !position.include?([x, y + 1])
  12.             position.push([x, y + 1])
  13.             route.push(route[i] + [2])
  14.             if route[i].size + 1 < max
  15.               more_step.push(route.index(route[i] + [2]))
  16.               if route[i].size + 1 < max-1
  17.                 delete.push(position.push([x, y + 1]),route.index(route[i] + [2]))
  18.               end
  19.             end
  20.           end
  21.           # 左
  22.           if !position.include?([x - 1, y])
  23.             position.push([x - 1, y])
  24.             route.push(route[i] + [4])
  25.             if route[i].size + 1 < max
  26.               more_step.push(route.index(route[i] + [4]))
  27.               if route[i].size + 1 < max-1
  28.                 delete.push(position.push([x - 1, y]),route.index(route[i] + [4]))
  29.               end
  30.             end
  31.           end
  32.           # 右
  33.           if !position.include?([x + 1, y])
  34.             position.push([x + 1, y])
  35.             route.push(route[i] + [6])
  36.             if route[i].size + 1 < max
  37.               more_step.push(route.index(route[i] + [6]))
  38.               if route[i].size + 1 < max-1
  39.                 delete.push(position.push([x - 1, y]),route.index(route[i] + [6]))
  40.               end
  41.             end
  42.           end
  43.           # 上
  44.           if !position.include?([x, y - 1])
  45.             position.push([x, y - 1])
  46.             route.push(route[i] + [8])
  47.             if route[i].size + 1 < max
  48.               more_step.push(route.index(route[i] + [8]))
  49.               if route[i].size + 1 < max-1
  50.                 delete.push(position.push([x, y - 1]),route.index(route[i] + [8]))
  51.               end
  52.             end
  53.           end
  54.           p delete
  55.           for i in delete
  56.             position.delete(i)
  57.           end
  58.           return position
  59.  
  60.         # 非无视障碍物的场合
  61.         else
  62.           # 下
  63.           if !position.include?([x, y + 1]) and !on_area?(x, y, type) and
  64.             (@battler.passable?(x, y, 2) or (on_area?(x, y + 1, type) and type != 4))
  65.             position.push([x, y + 1])
  66.             route.push(route[i] + [2])
  67.             if route[i].size + 1 < max
  68.               more_step.push(route.index(route[i] + [2]))
  69.             end
  70.             end
  71.           # 左
  72.           if !position.include?([x - 1, y]) and !on_area?(x, y, type) and
  73.             (@battler.passable?(x, y, 4) or (on_area?(x - 1, y, type) and type != 4))
  74.             position.push([x - 1, y])
  75.             route.push(route[i] + [4])
  76.             if route[i].size + 1 < max
  77.               more_step.push(route.index(route[i] + [4]))
  78.             end
  79.           end
  80.           # 右
  81.           if !position.include?([x + 1, y]) and !on_area?(x, y, type) and
  82.             (@battler.passable?(x, y, 6) or (on_area?(x + 1, y, type) and type != 4))
  83.             position.push([x + 1, y])
  84.             route.push(route[i] + [6])
  85.             if route[i].size + 1 < max
  86.               more_step.push(route.index(route[i] + [6]))
  87.             end
  88.           end
  89.           # 上
  90.           if !position.include?([x, y - 1]) and !on_area?(x, y, type) and
  91.           (@battler.passable?(x, y, 8) or (on_area?(x, y - 1, type) and type != 4))
  92.             position.push([x, y - 1])
  93.             route.push(route[i] + [8])
  94.             if route[i].size + 1 < max
  95.               more_step.push(route.index(route[i] + [8]))
  96.             end
  97.           end
  98.         end
  99.       end


脚本是这样···正常效果是要获得一个空心的菱形,可是实际应用效果却是无论怎么定义都获得一个最小的菱形···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-30 06:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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