下载地址
https://github.com/wangshub/wechat_jump_game
1,鼠标点击定距离计算按压时间,手工玩法
2,自动跳,找图形特征,计算起步和目标距离,计算按压时间。不过按压时间原来的不对,我调整了,乘以0.7,结果我的手机就很准了。
def jump(distance, delta_piece_y):
"""
跳跃一定的距离
"""
# 计算程序长度与截图测得的距离的比例
scale = 0.945 * 2 / head_diameter
actual_distance = distance * scale * (math.sqrt(6) / 2)
press_time = (-945 + math.sqrt(945 ** 2 + 4 * 105 *
36 * actual_distance)) / (2 * 105) * 1000*0.7#0.7是我加上去的
press_time *= press_coefficient
press_time = max(press_time, 200) # 设置 200ms 是最小的按压时间
press_time = int(press_time)
cmd = 'shell input swipe {x1} {y1} {x2} {y2} {duration}'.format(
x1=swipe_x1,
y1=swipe_y1,
x2=swipe_x2,
y2=swipe_y2,
duration=press_time + delta_piece_y
)
print(cmd)
adb.run(cmd)
return press_time
3.人工智能玩法
待续....