-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
53 lines (44 loc) · 1.2 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from PIL import ImageGrab,ImageOps
import pyautogui
import time
from numpy import *
from timeit import default_timer as timer
speed = 0
class Coordinates():
replayBtn = (479,454)
dinosaur = (189,490)#461
#271,489 = coordinate to check for the tree
#474 = y coordinate
def restartGame():
pyautogui.click(Coordinates.replayBtn)
pyautogui.keyDown('down')
def pressSpace():
pyautogui.keyUp('down')
pyautogui.keyDown('space')
time.sleep(0.09)
print("Jump")
pyautogui.keyUp('space')
pyautogui.keyDown('down')
def imageGrab():
#60
box = (Coordinates.dinosaur[0]+80+speed,Coordinates.dinosaur[1],Coordinates.dinosaur[0]+170+speed,Coordinates.dinosaur[1]+5)
image = ImageGrab.grab(box)
grayImage = ImageOps.grayscale(image)
a = array(grayImage.getcolors())
# print(a.sum())
return (a.sum())
def main():
start = time.time()
restartGame()
while True:
end = time.time()
# print(int(end-start))
if int(end-start)==4 :
start = time.time()
global speed
speed+=3
print("speed increased")
print(speed)
if(imageGrab()!=697):
pressSpace()
main()