File tree 1 file changed +54
-0
lines changed
1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ import pyautogui # pip install pyautogui
2
+ from PIL import Image , ImageGrab # pip install pillow
3
+ # from numpy import asarray
4
+ import time
5
+
6
+
7
+ def hit (key ):
8
+ pyautogui .press (key )
9
+ return
10
+
11
+
12
+ def isCollide (data ):
13
+
14
+ # for cactus
15
+ for i in range (329 , 425 ):
16
+ for j in range (550 , 650 ):
17
+ if data [i , j ] < 100 :
18
+ hit ("up" )
19
+ return
20
+
21
+ # Draw the rectangle for birds
22
+ # for i in range(310, 425):
23
+ # for j in range(390, 550):
24
+ # if data[i, j] < 100:
25
+ # hit("down")
26
+ # return
27
+
28
+ # return
29
+
30
+
31
+ if __name__ == "__main__" :
32
+ print ("Hey.. Dino game about to start in 3 seconds" )
33
+ time .sleep (2 )
34
+ # hit('up')
35
+
36
+ while True :
37
+ image = ImageGrab .grab ().convert ('L' )
38
+ data = image .load ()
39
+ isCollide (data )
40
+
41
+ # print(aarray(image))
42
+
43
+ # Draw the rectangle for cactus
44
+ # for i in range(315, 425):
45
+ # for j in range(550, 650):
46
+ # data[i, j] = 0
47
+
48
+ # # # # # Draw the rectangle for birds
49
+ # for i in range(310, 425):
50
+ # for j in range(390, 550):
51
+ # data[i, j] = 171
52
+
53
+ # image.show()
54
+ # break
You can’t perform that action at this time.
0 commit comments