微信跳一跳源码:直接跑就可以(这里只展示代码,具体运行是看视频学的,看视频里面没有代码):
from airscript.action import click
from airscript.screen import yolo_v5
yolo = yolo_v5("微信跳一跳:1.5")
from .res.ui import draw
import math
# print(0)
#计算小人和
import time
def jump(ts):
p = None
t = None
for i in ts:
if i.label=='小人':
p = i
elif t==None:
t = i
elif i.y<t.y:
t = i
if p and t and p.y>t.y:
ss = [p,t]
for i in ss:
if i.prob > 0.2:
draw.add_rect(i.label + str(i.prob), 1000, i.x, i.y, i.w, i.h)
# print(i)
s_x = p.x+p.w/2
s_y = p.y+p.h*0.85
t_x = t.x+t.w/2
t_y = t.y+t.h/2
draw.add_line('line',1000,s_x,s_y,t_x,t_y)
space = math.sqrt((s_x-t_x)**2+(s_y-t_y)**2)
time1 = space*1.05
#这里的时间用的是1.05倍,与自己的手机像素有关,自行调整
click(s_x,s_y,time1)
pass
while True:
ts = yolo.find_all()
jump(ts)
time.sleep(2)