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

Project1

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

[已经解决] 求个真斜四方向脚本

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
99 小时
注册时间
2011-3-19
帖子
41
1
发表于 2011-5-1 10:18:56 | 显示全部楼层
我原来改过一个。但是后来发现有个严重的问题。因为斜着走的缘故,地图上有一半格子走不到(国际象棋里的象)。而且和事件触发的手感也很差。后来就改回默认的了。


xfyx于2011-5-1 10:57补充以下内容:
#--------------------------------------------------------------------------
  # ● 下(左下)
  #     turn_ok : 此地可以更改朝向
  #--------------------------------------------------------------------------
  def move_down(turn_ok = true)
    unless @direction_fix
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
    end
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      turn_down
      @x -= 1
      @y += 1      
      increase_steps
      @move_failed = false
    else                                    # 不可以通过
      turn_down if turn_ok
      check_event_trigger_touch(@x, @y+1)   # 判断接触的事件启动
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 左(左上)
  #     turn_ok : 此地可以更改朝向
  #--------------------------------------------------------------------------
  def move_left(turn_ok = true)
    unless @direction_fix
      @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
    end
    if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y-1))
      turn_left
      @x -= 1
      @y -= 1
      increase_steps
      @move_failed = false
    else                                    # 不可以通过
      turn_left if turn_ok
      check_event_trigger_touch(@x-1, @y)   # 判断接触的事件启动
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 右(右下)
  #     turn_ok : 此地可以更改朝向
  #--------------------------------------------------------------------------
  def move_right(turn_ok = true)
    unless @direction_fix
      @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
    end
    if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y+1))
      turn_right
      @x += 1
      @y += 1
      increase_steps
      @move_failed = false
    else                                    # 不可以通过
      turn_right if turn_ok
      check_event_trigger_touch(@x+1, @y)   # 判断接触的事件启动
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 上(右上)
  #     turn_ok : 此地可以更改朝向
  #--------------------------------------------------------------------------
  def move_up(turn_ok = true)
    unless @direction_fix
      @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
    end
    if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y-1))
      turn_up
      @x += 1
      @y -= 1
      increase_steps
      @move_failed = false
    else                                    # 不可以通过
      turn_up if turn_ok
      check_event_trigger_touch(@x, @y-1)   # 判断接触的事件启动
      @move_failed = true
    end
  end


这应该算“伪”吧

点评

唔。。。伪的我自己也有写出来。。。。不过还是多谢你  发表于 2011-5-2 01:14
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 16:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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