加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Chrome Dino Automater.py 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
GauravSingh75 提交于 2020-08-06 17:51 . Chrome Dino Game Automater added
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化