-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChromeDino.py
54 lines (43 loc) · 1.24 KB
/
ChromeDino.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from os import truncate
import pyautogui
from PIL import Image , ImageGrab
# from numpy import asarray
import time
def hit(key):
pyautogui.keyDown(key)
def isCollide(data):
for i in range(300, 415):
for j in range(410, 610):
if data[i , j] < 100:
hit("down")
return True
for i in range(300, 415):
for j in range(600, 650):
if data[i , j] < 100:
hit("up")
return True
return False
# def draw():
# def takeScreenshot():
# return image()
if __name__ == "__main__":
print("Hey ... Dino game i about to start in 2 seconds")
time.sleep(2)
# hit('up')
while True:
# image = takeScreenshot()
image = ImageGrab.grab().convert('L')
data = image.load()
isCollide(data)
'''
# print(asarray(image))
# Draw the rectangle
for i in range(300, 415):
for j in range(600, 650):
data[i , j] = 0
for i in range(300, 415):
for j in range(410, 610):
data[i , j] = 171
image.show()
break
'''