导语:
小编今天突然打开微信小程序游戏,嗯🤔“跳一跳”。
跳了几把之后,ok稳居好友PK榜最后一位(⌐■_■),就很nice👍
难道是玩手机的姿势不对🤔躺着跳,坐着跳,站着跳
挤在地铁跳,蹲马在桶跳,乘电也在梯跳。。。。😑
就这样跳啊跳…费尽心思跳了一下午,也没超过 100 分,但排行榜里四分之三的人都超过三位数了……
真是扎心了老铁……
既然不会动手,那就用技术手段来实现高分✔
正文:
Python 跳一跳代码部分展示
def main():
"""
主函数
"""
op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,'
'然后打开跳一跳并【开始游戏】后再用本程序,确定开始?')
if not op:
print('bye')
return
print('程序版本号:{}'.format(VERSION))
debug.dump_device_info()
screenshot.check_screenshot()
i, next_rest, next_rest_time = (0, random.randrange(3, 10),
random.randrange(5, 10))
while True:
screenshot.pull_screenshot()
im = Image.open('./autojump.png')
# 获取棋子和 board 的位置
piece_x, piece_y, board_x, board_y = find_piece_and_board(im)
ts = int(time.time())
print(ts, piece_x, piece_y, board_x, board_y)
set_button_position(im)
jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2))
if DEBUG_SWITCH:
debug.save_debug_screenshot(ts, im, piece_x,
piece_y, board_x, board_y)
debug.backup_screenshot(ts)
im.close()
i += 1
if i == next_rest:
print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time))
for j in range(next_rest_time):
sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j))
sys.stdout.flush()
time.sleep(1)
print('\n继续')
i, next_rest, next_rest_time = (0, random.randrange(30, 100),
random.randrange(10, 60))
# 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
time.sleep(random.uniform(0.9, 1.2))
if __name__ == '__main__':
main()
实验结果:
今天”跳一跳“很nice👍榜一,明天继续,冲鸭冲鸭~
结尾:
需要完整的项目源码,安装程序的私信我即可哟!