-
Notifications
You must be signed in to change notification settings - Fork 0
/
dino2.py
42 lines (35 loc) · 981 Bytes
/
dino2.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
import pyautogui
from PIL import Image, ImageGrab
import time
def hit(key):
pyautogui.keyDown(key)
def isCollide(data):
for i in range(186, 520):
for j in range(474, 550):
if data[i, j] < 100:
return True
return False
def isCollideInNight(data):
for i in range(186, 520):
for j in range(474, 550):
if data[i, j] > 165:
return True
return False
def isNightMode(data):
for i in range(200, 300):
for j in range(660, 700):
if data[i, j] < 100:
return isCollideInNight(data)
return isCollide(data)
if __name__ == "__main__":
time.sleep(3)
while True:
image = ImageGrab.grab().convert('L')
data = image.load()
if isNightMode(data):
hit("up")
# draw a shape and show image for debug
for i in range(186, 425):
for j in range(480, 558):
data[i, j] = 165
image.show()