본문 바로가기

Python

T-Rex Game Bot

http://www.trex-game.skipser.com/


피하기 게임 봇.


from PIL import ImageGrab, ImageOps
import pyautogui
import time
from numpy import *
class Cordinates():
replayBtn = (340, 390)
dinasaur = (288, 401)
def restartGame():
pyautogui.click(Cordinates.replayBtn)
pyautogui.keyDown('down')
def pressSpace():
pyautogui.keyUp('down')
pyautogui.keyDown('space')
time.sleep(0.18)
print("Jump")
pyautogui.keyUp('space')
pyautogui.keyDown('down' )
def imageGrab():
box = (Cordinates.dinasaur[0]+1, Cordinates.dinasaur[1]+5,
Cordinates.dinasaur[0]+12 , Cordinates.dinasaur[1]+8)
image = ImageGrab.grab(box)
grayImage = ImageOps.grayscale(image)
a = array(grayImage.getcolors())
print(a.sum())
return a.sum()

def main():
restartGame()
while True:
if(imageGrab() > 280):
pressSpace()
#time.sleep(0.1)
main()



'Python' 카테고리의 다른 글

Scrapy 간단 Selector  (0) 2019.02.24
웹 크롤링 이슈 - 저작권, 사이트 크롤링 정책  (0) 2019.02.24
ImportError: cannot import name 'MongoClient'  (4) 2018.05.29
Scrapy 참고 사이트  (0) 2018.05.28
Scrapy 에러  (0) 2018.05.27