Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 23707ce

Browse files
committed
Chrome Dino Game Automator
1 parent 68e8b61 commit 23707ce

File tree

1 file changed

+56
-0
lines changed
  • Mini Project/dino Game Automator

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
Author : Robin Singh
3+
4+
"""
5+
import pyautogui
6+
import PIL
7+
from PIL import Image,ImageGrab
8+
import time
9+
10+
def key_hit(key):
11+
pyautogui.keyDown(key)
12+
return
13+
14+
def take_screenShot():
15+
image = ImageGrab.grab().convert('L')#Converts RGB scale To grey Scale
16+
return image
17+
18+
def is_collide(data):
19+
for i in range(300, 415):
20+
for j in range(410, 563):
21+
if data[i, j] < 100:
22+
key_hit("down")
23+
return
24+
25+
for i in range(320, 415):
26+
for j in range(563, 650):
27+
if data[i, j] < 100:
28+
key_hit("up")
29+
return
30+
return
31+
32+
33+
if __name__ == '__main__':
34+
print("Dino game will start in just few secs")
35+
time.sleep(3)
36+
key_hit('up')
37+
while True:
38+
img = take_screenShot()
39+
data = img.load() #will return pixel date as in the form of array
40+
is_collide(data)
41+
# key_hit("up")
42+
43+
44+
# # drawing rectangle fr cactus
45+
# for i in range(310, 415):
46+
# for j in range(563, 650):
47+
# data[i,j] = 0
48+
# # drawing rectagle for birds
49+
# for i in range(300, 415):
50+
# for j in range(410, 563):
51+
# data[i,j] = 171
52+
53+
54+
55+
# img.show()
56+
# break

0 commit comments

Comments
 (0)