一段python代码,用来录入弹道并生成相对位移值(x,y)
使用说明
1、先打开游戏,拿一把枪,对着墙扫一梭子,然后你会得到上图那样一串子弹痕迹,截图保存。
2、然后运行脚本,打开图片,把鼠标逐一放在弹孔上,按+按键,会记录此时鼠标的坐标。
3、把弹道全部输入后,按-按键,会输出相对运动数组。
4、鼠标按照这个数组移动就可以开枪后完美停留在中心点。
5、当然,还需要考虑开枪间隔时间的问题,这个需要逐帧分析。
代码如下
import keyboard
import mouse
# 计算弹道
coordinates = []
new_coordinates = []
def on_key_event(event):
if event.event_type == keyboard.KEY_DOWN:
if event.name == '+':
x, y = mouse.get_position()
print(x,y)
coordinates.append([x, y])
elif event.name == '-':
print(coordinates)
for i in range(len(coordinates) - 1):
diff_x = coordinates[0] - coordinates[i + 1][0]
diff_y = coordinates[1] - coordinates[i + 1][1]
new_coordinates.append([diff_x, diff_y])
print(new_coordinates)
keyboard.on_press(on_key_event)
keyboard.wait('esc')


楼主辛苦了,谢谢楼主,楼主好人一生平安!
楼主辛苦了,谢谢楼主,楼主好人一生平安!
卧槽!无奈本人没文化,一句卧槽行天下!