-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (46 loc) · 1.33 KB
/
main.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
52
53
import pyautogui
import time
pyautogui.PAUSE = 0.05 # time (seconds) between each click
DELAY = 0.0 # delay reading each time
BG = (211,247,255) # blue sky
REGION_OLD = (851,500,217,1) # Old region
REGION = (868,454,188,1) # area to screenshot
LEFT = (0,0)
RIGHT = (187,0)
def start():
print('starting...')
time.sleep(1)
# press space once to start the ga me
pyautogui.press('space')
time.sleep(0.5)
# press arrow button twice to negate first two empty taps
pyautogui.press('left')
pyautogui.press('right')
# time.sleep(DELAY)
def main():
start()
curr = "" # current button to press
stopcount = 0 # to restart after the game dies
while True:
# Taking screenshot to analyze pixels
im = pyautogui.screenshot(region=REGION)
colorL = im.getpixel(LEFT)
colorR = im.getpixel(RIGHT)
if colorR==BG and colorL==BG: # both are the sky
curr = ""
stopcount += 1
if stopcount>10:
stopcount=0
start()
continue
elif colorR==BG:
curr = "right"
elif colorL==BG:
curr = "left"
if curr:
pyautogui.press(curr)
pyautogui.press(curr)
stopcount = 0
time.sleep(DELAY)
if __name__ == "__main__":
main()