当前位置:网站首页>跳一跳小游戏辅助(手动版本)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() #展示出来 边栏推荐
- Kwai 616 war report was launched, and the essence was thrown away for the second time to lead the new wave. Fast brand jumped to the top 3 of the hot list
- 【ELT.ZIP】OpenHarmony啃论文俱乐部—见证文件压缩系统EROFS
- RMAN备份数据库_双重备份备份集(Duplexing Backup Sets)
- Some recursive and iterative problem solving ideas of binary tree (clear and easy to understand)
- IVX 启航
- What is generics and the use of generics in collections [easy to understand]
- Qi v1.2.4协议 之 定频调压方案
- Redis configuration (Internet access, password)
- [deeply understand tcapulusdb technology] one click installation of tmonitor background
- [deeply understand tcapulusdb technology] tmonitor system upgrade
猜你喜欢

03 runtime data area overview and threads

Uncover ges super large scale graph computing engine hyg: Graph Segmentation

158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能

安装spark + 用命令运行scala相关项目 + crontab定时执行

【深入理解TcaplusDB技术】Tmonitor后台一键安装

IVX sailing

【深入理解TcaplusDB技术】一键安装Tmonitor后台

【深入理解TcaplusDB技术】Tmonitor系统升级

【深入理解TcaplusDB技术】单据受理之建表审批
![[in depth understanding of tcapulusdb technology] tcapulusdb model](/img/10/f94a5e1ebeaa803c754dd77351950f.png)
[in depth understanding of tcapulusdb technology] tcapulusdb model
随机推荐
RMAN backup database_ Restart RMAN backup
【深入理解TcaplusDB技术】TcaplusDB运维单据
[path planning] how to add moving objects to a path
Command records of common data types for redis cli operations
[deeply understand tcapulusdb technology] cluster management operation
05 virtual machine stack
Leetcode force buckle (Sword finger offer 26-30) 26 Substructure of tree 27 Image of binary tree 28 Symmetric binary tree 29 Print matrix 30 clockwise Stack containing min function
JSP页面运行却显示源码
[deeply understand tcapulusdb technology] tcapulusdb import data
El table highly adaptive
视觉SLAM十四讲 第9讲 卡尔曼滤波
Training of long and difficult sentences in postgraduate entrance examination day86
Move graph explorer to jupyterab: use ges4jupyter to connect ges and explore graphs
Redis trend - NVM memory
[deeply understand tcapulusdb technology] tmonitor system upgrade
Slam visuel Leçon 14 leçon 9 filtre Kalman
C# asp,net core框架传值方式和session使用
【深入理解TcaplusDB技术】Tmonitor后台一键安装
One article solves all search backtracking problems of Jianzhi offer
华为云SRE确定性运维专刊(第一期)