查看: 1488|回复: 0

[已经过期] 帮忙SLG寻路代码

[复制链接]
梦石
0
星屑
66
在线时间
91 小时
注册时间
2012-8-15
回帖
43
发表于 2012-9-30 16:45:59 | 显示全部楼层 |阅读模式

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

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

×
def find_next_point(x, y, r)
    return if !@path_hash[[x, y, r]].nil?
    @path << [x, y] if(!@path.include?([x, y]))
    @path_hash[[x, y]] = true
     find_next_point(x - 1,y, r - 1) if r > 0 && @coordinate[x-1,y] == 0
     find_next_point(x + 1,y, r - 1) if r > 0 && @coordinate[x+1,y] == 0
     find_next_point( x,y + 1, r - 1) if r > 0 && @coordinate[x,y+1] == 0
     find_next_point( x,y - 1, r - 1) if r > 0 && @coordinate[x,y-1] == 0
     end   


这个是移动范围,但是寻路计算不出来.求教
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部