From ed6bef0ce48c982b2830eaa8a099eb999aa48fe6 Mon Sep 17 00:00:00 2001 From: Kapil_jain <72228799+kapiljaingit02@users.noreply.github.com> Date: Sat, 3 Oct 2020 19:48:52 +0530 Subject: [PATCH 1/2] Add files via upload --- Chrome_Dinosaur_Game.py | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Chrome_Dinosaur_Game.py diff --git a/Chrome_Dinosaur_Game.py b/Chrome_Dinosaur_Game.py new file mode 100644 index 0000000..5b94b61 --- /dev/null +++ b/Chrome_Dinosaur_Game.py @@ -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 + + From 5a90934cbb30ec85793c315ca1483f7a10d23303 Mon Sep 17 00:00:00 2001 From: Kapil_jain <72228799+kapiljaingit02@users.noreply.github.com> Date: Sat, 3 Oct 2020 19:51:21 +0530 Subject: [PATCH 2/2] Update Contributor.md --- Contributor.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Contributor.md b/Contributor.md index d066caf..3395034 100644 --- a/Contributor.md +++ b/Contributor.md @@ -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)