python版微信跳一跳游戏辅助

yipeiwu_com5年前Python基础

本文实例为大家分享了微信跳一跳游戏辅助python代码,供大家参考,具体内容如下

import os
import PIL
import numpy
import matplotlib

matplotlib.use('TKAgg')
import matplotlib.pyplot as plt
import time

from matplotlib.animation import FuncAnimation

# 是否需要进行图片更新
need_update = True

def get_screen_image():
 # 截取手机当前图片
 os.system('adb shell screencap -p /sdcard/screen.png')
 # 拉取到PC端
 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 touchscreen swipe 320 410 320 410 %d" % (distance * 1.35))


def on_clack(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(2)
 axes_image.set_array(get_screen_image())
 # 已刷新,设置为false
 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_clack)
# 定时更新
ani = FuncAnimation(figure, update_screen, interval=50, blit=True)
plt.show()

更多内容大家可以参考专题《微信跳一跳》进行学习。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python中if __name__ == '__main__'作用解析

当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介 绍一下它的作用.     &n...

PyCharm2018 安装及破解方法实现步骤

PyCharm2018 安装及破解方法实现步骤

PyCharm就是Python语言开发中一个很受欢迎的IDE,界面类似于visual studio,android studio,集成的功能也很多。 1>. 安装 首先要...

Python的Flask框架标配模板引擎Jinja2的使用教程

Jinja2需要Python2.4以上的版本。 安装 按照Jinja有多种方式,你可以根据需要选择不同的按照方式。 使用easy_install 或pip: #sudo e...

python+selenium实现QQ邮箱自动发送功能

python+selenium实现QQ邮箱自动发送功能

python实现从登录到自动发送qq邮件,供大家参考,具体内容如下 qq邮箱登录注意问题 账户密码登录框是写在一个iframe上的,所以我们要先进入iframe中才能定位到下面的两个输入...

python3基于TCP实现CS架构文件传输

本文实例为大家分享了python3实现CS架构文件传输的具体代码,供大家参考,具体内容如下 1、目标: 基于tcp实现CS架构的文件传输 指令列表:(1)get:从服务器端下载文件 &n...