Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Chrome_Dinosaur_Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pyautogui # pip install pyautogui
from PIL import Image, ImageGrab # pip install pillow
# from numpy import asarray
import time

def hit(key):
pyautogui.keyDown(key)
return

def isCollide(data):
# Draw the rectangle for birds
for i in range(725, 825):
for j in range(280, 328):
if data[i, j] > 140:
hit("up")
return

for i in range(700, 805):
for j in range(230, 275):
if data[i, j] > 140 and data[i, j] < 160:
hit("down")
return
return

if __name__ == "__main__":
print("Hey.. Dinosour game about to start in 3 seconds")
time.sleep(3)
hit('up')

while True:
image = ImageGrab.grab().convert('L')
data = image.load()
isCollide(data)

#### below code is used to test the code with game by building dummy image on screen
# # Draw the rectangle for cactus
# for i in range(700, 715):
# for j in range(230, 275):
# data[i, j] = 140
# # Draw the rectangle for birds
# for i in range(710, 730):
# for j in range(280, 330):
# data[i, j] = 160
# image.show()
# break


1 change: 1 addition & 0 deletions Contributor.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- [VishnuThokala](https://github.com/VishnuThokala)
- [Shaurya026](https://github.com/Shaurya026)
- [Jeevesh-Joshi](https://github.com/Jeevesh-Joshi)
- [Kapil-Jain](https://github.com/kapiljaingit02)