代码拉取完成,页面将自动刷新
import pyautogui # pip install pyautogui
from PIL import Image, ImageGrab # pip install pillow
# from numpy import asarray
import time
def hit(key):
pyautogui.press(key)
return
def isCollide(data):
# for cactus
for i in range(329, 425):
for j in range(550, 650):
if data[i, j] < 100:
hit("up")
return
# Draw the rectangle for birds
# for i in range(310, 425):
# for j in range(390, 550):
# if data[i, j] < 100:
# hit("down")
# return
# return
if __name__ == "__main__":
print("Hey.. Dino game about to start in 3 seconds")
time.sleep(2)
# hit('up')
while True:
image = ImageGrab.grab().convert('L')
data = image.load()
isCollide(data)
# print(aarray(image))
# Draw the rectangle for cactus
# for i in range(315, 425):
# for j in range(550, 650):
# data[i, j] = 0
# # # # # Draw the rectangle for birds
# for i in range(310, 425):
# for j in range(390, 550):
# data[i, j] = 171
# image.show()
# break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。