-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
70 lines (57 loc) · 1.23 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pyautogui as p
from PIL import Image, ImageGrab
import time
'''
Use chrome://dino/
then press space to play
now run this script. :)
'''
def hit(key):
p.keyDown(key)
return
def isCollide(data):
# when brid
for i in range(200, 230):
# for Y axis
for j in range(350, 410):
#255 is white the 100 pixel is shellow dark
if data[i, j] < 100:
hit("down")
return
#when cactus arive
# for X axis and width
for i in range(240, 270):
# for Y axis and height
for j in range(410, 480):
#255 is white the 100 pixel is shellow dark
if data[i, j] < 100:
hit("up")
return
return
#image.show()
def showBlock(data):
#when bird X
for i in range(200, 230):
# for Y axis
for j in range(350, 410):
#255 is white the 100 pixel is shellow dark
data[i, j] = 100
#when cactus arive
# for X axis and width
for i in range(230, 260):
# for Y axis and height
for j in range(410, 480):
#255 is white the 100 pixel is shellow dark
data[i, j] = 0
if __name__ == "__main__":
print('Let Begin....')
time.sleep(0)
#hit('up')
while True:
image = ImageGrab.grab().convert('L')
#load image for show
data = image.load()
isCollide(data)
#showBlock(data)
#image.show()
#break