赞 | 0 |
VIP | 17 |
好人卡 | 0 |
积分 | 1 |
经验 | 1022914 |
最后登录 | 2017-2-4 |
在线时间 | 10 小时 |
Lv1.梦旅人 月下可怜人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 10 小时
- 注册时间
- 2005-11-23
- 帖子
- 4085
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
功能:
脚本:
- #==============================================================================
- # ■ 全方向移动
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- last_real_x = @real_x
- last_real_y = @real_y
- last_moving = moving?
- #全方向移动
- all_move_by_input
- super
- update_scroll(last_real_x, last_real_y)
- update_vehicle
- update_nonmoving(last_moving)
- end
- #--------------------------------------------------------------------------
- # ● 判断是否接触事件(不可通行情况下)
- # x : X 坐标
- # y : Y 坐标
- #--------------------------------------------------------------------------
- def all_check_event_trigger_touch(x, y)
- return false if $game_map.interpreter.running?
- result = false
- allEvents = $game_map.events_xy(x, y)
- result = true unless allEvents.empty?
- for event in allEvents
- if [1,2].include?(event.trigger) and event.priority_type == 1
- event.start
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 处理输入方向键后的移动
- #--------------------------------------------------------------------------
- def all_move_by_input
- return unless movable?
- return if $game_map.interpreter.running?
- move_dir(Input.dir8)
- end
- #--------------------------------------------------------------------------
- # ● 转向判断
- #--------------------------------------------------------------------------
- def dir_fact(x1, y1, x2, y2, d1, d2)
- dir = 0
- dir +=1 if passable?(x1, y1) #右下
- dir +=2 if passable?(x2, y2) #左下
- if dir > 0
- return (rand(10) > 4 ? move_dir(d1) : move_dir(d2)) if dir == 3
- return move_dir(d2) if dir == 2
- return move_dir(d1) if dir == 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 移动方向
- #--------------------------------------------------------------------------
- def move_dir(d)
- return all_move_lower_left if d == 1
- return all_move_down if d == 2
- return all_move_lower_right if d == 3
- return all_move_left if d == 4
- return all_move_right if d == 6
- return all_move_upper_left if d == 7
- return all_move_up if d == 8
- return all_move_upper_right if d == 9
- end
- #--------------------------------------------------------------------------
- # ● 向下移动
- # turn_ok : 此地可以更改朝向
- #--------------------------------------------------------------------------
- def all_move_down(turn_ok = true)
- if passable?(@x, @y+1) # 可以通过
- turn_down
- @y = $game_map.round_y(@y+1)
- @real_y = (@y-1)*256
- increase_steps
- @move_failed = false
- else # 下方向不可通过
- if all_check_event_trigger_touch(@x, @y+1) # 判断接触的事件启动
- turn_down if turn_ok
- @move_failed = true
- return
- end
- dir_fact(@x+1, @y+1, @x-1, @y+1, 3, 1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向左移动
- # turn_ok : 此地可以更改朝向
- #--------------------------------------------------------------------------
- def all_move_left(turn_ok = true)
- if passable?(@x-1, @y) # 可以通过
- turn_left
- @x = $game_map.round_x(@x-1)
- @real_x = (@x+1)*256
- increase_steps
- @move_failed = false
- else # 不可以通过
- if all_check_event_trigger_touch(@x-1, @y) # 判断接触的事件启动
- turn_left if turn_ok
- @move_failed = true
- return
- end
- dir_fact(@x-1, @y+1, @x-1, @y-1, 1, 7)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右移动
- # turn_ok : 此地可以更改朝向
- #--------------------------------------------------------------------------
- def all_move_right(turn_ok = true)
- if passable?(@x+1, @y) # 可以通过
- turn_right
- @x = $game_map.round_x(@x+1)
- @real_x = (@x-1)*256
- increase_steps
- @move_failed = false
- else # 不可以通过
- if all_check_event_trigger_touch(@x+1, @y) # 判断接触的事件启动
- turn_right if turn_ok
- @move_failed = true
- return
- end
- dir_fact(@x+1, @y-1, @x+1, @y+1, 9, 3)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向上移动
- # turn_ok : 此地可以更改朝向
- #--------------------------------------------------------------------------
- def all_move_up(turn_ok = true)
- if passable?(@x, @y-1) # 可以通过
- turn_up
- @y = $game_map.round_y(@y-1)
- @real_y = (@y+1)*256
- increase_steps
- @move_failed = false
- else # 不可以通过
- if all_check_event_trigger_touch(@x, @y-1) # 判断接触的事件启动
- turn_up if turn_ok
- @move_failed = true
- return
- end
- dir_fact(@x-1, @y-1, @x+1, @y-1, 7, 9)
- end
- end
- #--------------------------------------------------------------------------
- # ● 左下移动
- #--------------------------------------------------------------------------
- def all_move_lower_left
- 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))
- @x -= 1
- @y += 1
- increase_steps
- @move_failed = false
- else
- @move_failed = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右下移动
- #--------------------------------------------------------------------------
- def all_move_lower_right
- 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))
- @x += 1
- @y += 1
- increase_steps
- @move_failed = false
- else
- @move_failed = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 向左上移动
- #--------------------------------------------------------------------------
- def all_move_upper_left
- 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))
- @x -= 1
- @y -= 1
- increase_steps
- @move_failed = false
- else
- @move_failed = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右上移动
- #--------------------------------------------------------------------------
- def all_move_upper_right
- 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))
- @x += 1
- @y -= 1
- increase_steps
- @move_failed = false
- else
- @move_failed = true
- end
- end
- end
复制代码
范例:
http://rpg.blue/upload_program/d ... 81011_104188782.rar
截图:(注意红圈内的移动方式)
|
|