Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyautogui, time, os, numpy, mss
- pyautogui.PAUSE = 0.001
- first = True
- game_coords = (239, 251, 738, 741)
- def kick_ball(screen):
- global game_coords, first
- for y in range(0, len(screen), 18):
- for x in range(0, len(screen[y]), 18):
- if(screen[y][x][0] == 0 and screen[y][x][1] == 0 and screen[y][x][2] == 0):
- print('Found ball at x: {}, y: {}'.format(x, y))
- click_x = x + game_coords[0]
- if(first):
- click_y = y + game_coords[1]
- first = False
- else:
- click_y = y + game_coords[1] + 160
- pyautogui.click(click_x, click_y)
- return 0
- for i in range(5, 0, -1):
- print('Waiting {} more seconds...'.format(i))
- time.sleep(1)
- os.system('cls')
- while True:
- begin = time.time()
- with mss.mss() as sct:
- screen = sct.grab(game_coords)
- print('Screenshoot time: {}'.format(time.time() - begin))
- begin = time.time()
- screen = numpy.array(screen)
- print('Nympy take: {}'.format(time.time() - begin))
- begin = time.time()
- kick_ball(screen)
- print('Process took: {}\n'.format(time.time() - begin))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement