Project1
标题:
如何……随机跳跃
[打印本页]
作者:
ichijouziken
时间:
2009-1-6 07:41
标题:
如何……随机跳跃
主角按决定键后,让这个事件随机跳跃到一个位置,也就是 X坐标+随机数 Y坐标+随机数,这个随机数还要有一个范围……那么我应该如何操作? [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
九夜神尊
时间:
2009-1-6 08:01
为你写了个定做
不认可对不起我
#==================================================================
#使跳跃支持变量操作
#
#使用方法,约定如下
# 当x坐标设定为99时,跳跃步数为 变量甲
# 当y坐标设定为99时,跳跃步数为 变量乙
# 变量甲 乙,在脚本中设定,在跳跃之前
# 先处理这两个变量,然后跳跃步数填为99级可
#====================================================================
class Game_Character
#--------------------------------------------------------------------------
# ● 跳跃
# x_plus : X 坐标增加值
# y_plus : Y 坐标增加值
#--------------------------------------------------------------------------
def jump(x_plus, y_plus)
# 增加值不是 (0,0) 的情况下
@swtf_x = 1 #当填写99时,x使用变量ID
@swtf_y = 2 #当填写99时,y使用变量ID
x_plus = $game_variables[@swtf_x] if x_plus = 99
y_plus = $game_variables[@swtf_y] if x_plus = 99
if x_plus != 0 or y_plus != 0
# 横侧距离长的情况下
if x_plus.abs > y_plus.abs
# 变更左右方向
x_plus < 0 ? turn_left : turn_right
# 竖侧距离长的情况下
else
# 变更上下方向
y_plus < 0 ? turn_up : turn_down
end
end
# 计算新的坐标
new_x = @x + x_plus
new_y = @y + y_plus
# 增加值为 (0,0) 的情况下、跳跃目标可以通行的场合
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
# 矫正姿势
straighten
# 更新坐标
@x = new_x
@y = new_y
# 距计算距离
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
# 设置跳跃记数
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
# 清除停止记数信息
@stop_count = 0
end
end
end
复制代码
不会用联系我 [LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者:
ichijouziken
时间:
2009-1-7 07:06
这个具体来说应该如何用呢?
作者:
九夜神尊
时间:
2009-1-7 07:08
看说明咯
作者:
ichijouziken
时间:
2009-1-14 07:16
看不懂
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1