Skip to content

Instantly share code, notes, and snippets.

@mjdargen
Created July 21, 2020 17:00
Show Gist options
  • Save mjdargen/c5b00c625898a24b1fb3c7e34ba0824e to your computer and use it in GitHub Desktop.
Save mjdargen/c5b00c625898a24b1fb3c7e34ba0824e to your computer and use it in GitHub Desktop.
# pip install pyautogui
import pyautogui
# pip install pillow
from PIL import ImageGrab
import time
def click(key):
pyautogui.keyDown(key)
return
def isCollision(data):
# Check colison for birds
for i in range(650, 800):
for j in range(1100, 1200):
if data[i, j] < 171:
click("down")
return
# Check colison for cactus
for i in range(650, 800):
for j in range(1300, 1350):
if data[i, j] < 100:
click("up")
return
return
if __name__ == "__main__":
time.sleep(5)
click('up')
while True:
image = ImageGrab.grab().convert('L')
data = image.load()
isCollision(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment