for i in range(start_y, int((height * 2) / 3)): start_point = im[0, i] if x2 or y2: break x2_temp = 0 x2_num = 0 for j in range(width): next_point = im[j, i] if abs(j - x1) < body_width: continue # 棋盘为圆 if abs(next_point[0] - start_point[0]) + abs(next_point[1] - start_point[1]) + abs( next_point[2] - start_point[2]) > 10: x2_temp += j x2_num += 1 if x2_temp: x2 = x2_temp / x2_num # 按实际的角度通过tan值来算计算下一个棋盘的中心点的Y轴坐标 y2 = y1 - abs(x2 - x1) * abs(sample_y1 - sample_y2) / abs(sample_x1 - sample_x2) if not all((x2, y2)): return 0, 0, 0, 0 return x1, y1, x2, y2
时间: 2024-01-13 15:05:13 浏览: 74
这段代码是 find() 函数的实现,用于找到跳跃目标的坐标。首先,它从屏幕截图中的 start_y 行开始,逐行扫描像素点,并找到第一个与起始点像素值不同的像素点,即为跳跃目标的上方一行棋盘。接着,它再扫描这一行棋盘,找到棋盘中心点的 x 坐标 x2,然后通过计算得到棋盘中心点的 y 坐标 y2。最后返回 x1, y1, x2, y2 四个值,其中 x1, y1 表示起始点的坐标,x2, y2 表示跳跃目标的坐标。
阅读全文