简单的微信跳一跳游戏,半自动辅助 有意思

# !/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = '吓彬'
'''
这是一个半自动的物理辅助脚本
针对微信跳一跳游戏
可以用来称霸你的朋友圈哦
因为是半自动的,所以要高分还是需要耐心的
点击自己本身,然后再点击要达到的目的地
系统会自动发送跳的指令

在这之前:
你需要用数据线将手机连接到电脑(只针对安卓手机,苹果闪一边)
然后自己安装好你手机的adb驱动
怎么运行,就不用写那么详细了吧
'''
import os
import PIL,numpy
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import time

need_update = True

def get_screen_image():
    os.system('adb shell screencap -p /sdcard/screen.png')#获取当前界面的手机截图
    os.system('adb pull /sdcard/screen.png')#下载当前这个截图到当前电脑当前文件夹下
    return numpy.array(PIL.Image.open('screen.png'))

def jump_to_next(point1, point2):#计算炫的长度
    x1, y1 = point1; x2, y2 = point2
    distance = ((x2-x1)**2 + (y2-y1)**2)**0.5
    os.system('adb shell input swipe 320 410 320 410 {}'.format(int(distance*1.35)))

def on_calck(event, coor=[]):#绑定的鼠标单击事件
    global need_update
    coor.append((event.xdata, event.ydata))
    if len(coor) == 2:
        jump_to_next(coor.pop(), coor.pop())
    need_update = True

def update_screen(frame):#更新图片 /从画图片
    global need_update
    if need_update:
        time.sleep(1)
        axes_image.set_array(get_screen_image())
        need_update = False
    return axes_image,

figure = plt.figure()#创建一个空白的图片对象/创建一张图片
axes_image = plt.imshow(get_screen_image(), animated=True)#把获取的图片话在坐标轴上面
figure.canvas.mpl_connect('button_press_event', on_calck)
ani = FuncAnimation(figure, update_screen, interval=50, blit=True)
plt.show()

猜你喜欢

转载自blog.csdn.net/kina2001/article/details/79080746