当前位置:网站首页>跳一跳小游戏辅助(手动版本)py代码实现
跳一跳小游戏辅助(手动版本)py代码实现
2022-06-25 18:19:00 【幻丶城】
核心思路就是一个勾股定理的作用。通过2次计算完成跳跃,这些包我都打了注释。。。怎么安装,包安装方法 pip install 包名字,包安装完成就是adb。。百度安装。。配置环境变量。。。注意:单纯研究游戏原理。和练习py才写的,切勿滥用。否则后果自负。
#!/usr/bin/python
#-*-coding:utf-8 -*-
#FileName:wechat_main.py
#Author:gjt
#Date:2018/1/6 20:45
#os模块包含普通操作系统的功能
import os
#是python image library的缩写,,图像处理模块 numpy是python的一个科学计算库
import PIL,numpy
#matplotlib绘制直线,第二个矩形区域,Pyplot绘图
import matplotlib.pyplot as plt
#自定义动画函数
from matplotlib.animation import FuncAnimation
#py的时间模块
import time
need_updata = 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')) #image需要大写。
#计算弦长
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_click(event,coor=[]):
global need_updata
coor.append((event.xdata,event.ydata))
if len(coor)==2:
jump_to_next(coor.pop(),coor.pop())
need_updata = True
#重新绘制图片
def updata_screen(frame):
global need_updata
if need_updata:
time.sleep(1)
axes_image.set_array(get_screen_image())
need_updata = False
return axes_image,
figure = plt.figure()#创建一个空白区域(设置图片对象)生成一张图片
axes_image = plt.imshow(get_screen_image(),animated = True); #把图片拿到
figure.canvas.mpl_connect('button_press_event',on_click)
ani = FuncAnimation(figure,updata_screen,interval=5,blit=True)
plt.show() #展示出来
边栏推荐
- 【深入理解TcaplusDB技术】单据受理之事务执行
- 【深入理解TcaplusDB技术】TcaplusDB构造数据
- GNU nano
- Training of long and difficult sentences in postgraduate entrance examination day85
- [in depth understanding of tcapulusdb technology] tcapulusdb business data backup
- Dell R530内置热备盘状态变化说明
- [in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
- [deeply understand tcapulusdb technology] one click installation of tmonitor background
- Good news | Haitai Fangyuan has passed the cmmi-3 qualification certification, and its R & D capability has been internationally recognized
- JVM problem replication
猜你喜欢
[deeply understand tcapulusdb technology] cluster management operation
Optimization of lazyagg query rewriting in parsing data warehouse
Class 02 loader subsystem
IVX sailing
[deeply understand tcapulusdb technology] create a game area for document acceptance
跨境电商亚马逊、eBay、Shopee、Lazada、速卖通、沃尔玛、阿里国际等平台,怎样进行自养号测评更安全?
Deep learning network model
JVM understanding
Article 7: there is no code prompt in clion,,,
Pycharm 使用过程中碰到问题
随机推荐
. How to exit net worker service gracefully
Training of long and difficult sentences in postgraduate entrance examination day92
Under what circumstances do you need to manually write the @bean to the container to complete the implementation class
跨境电商亚马逊、eBay、Shopee、Lazada、速卖通、沃尔玛、阿里国际等平台,怎样进行自养号测评更安全?
Training of long and difficult sentences in postgraduate entrance examination day87
03 runtime data area overview and threads
Anaconda download Tsinghua source
Training of long and difficult sentences in postgraduate entrance examination day86
Training of long and difficult sentences in postgraduate entrance examination day88
Addition, deletion, modification and query of mysql~ tables (detailed and easy to understand)
【深入理解TcaplusDB技术】TcaplusDB导入数据
anaconda下载清华源
【ELT.ZIP】OpenHarmony啃论文俱乐部—见证文件压缩系统EROFS
【深入理解TcaplusDB技术】TcaplusDB常规单据
What is an operator?
JSP页面运行却显示源码
158_ Model_ Power Bi uses DAX + SVG to open up almost all possibilities for making business charts
Redis configuration (Internet access, password)
快手616战报首发,次抛精华引新浪潮,快品牌跃入热榜top3
Hash of redis command