Advertisement
Guest User

Untitled

a guest
Jul 13th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. import pyautogui, time, os, numpy, mss
  2. pyautogui.PAUSE = 0.001
  3.  
  4. first = True
  5. game_coords = (239, 251, 738, 741)
  6.  
  7. def kick_ball(screen):
  8.     global game_coords, first
  9.    
  10.     for y in range(0, len(screen), 18):
  11.         for x in range(0, len(screen[y]), 18):
  12.             if(screen[y][x][0] == 0 and screen[y][x][1] == 0 and screen[y][x][2] == 0):
  13.                 print('Found ball at x: {}, y: {}'.format(x, y))
  14.                 click_x = x + game_coords[0]
  15.                 if(first):
  16.                     click_y = y + game_coords[1]
  17.                     first = False
  18.                 else:
  19.                     click_y = y + game_coords[1] + 160
  20.                 pyautogui.click(click_x, click_y)
  21.                 return 0
  22.  
  23. for i in range(5, 0, -1):
  24.     print('Waiting {} more seconds...'.format(i))
  25.     time.sleep(1)
  26.     os.system('cls')
  27.  
  28. while True:
  29.     begin = time.time()
  30.     with mss.mss() as sct:
  31.         screen = sct.grab(game_coords)
  32.     print('Screenshoot time: {}'.format(time.time() - begin))
  33.     begin = time.time()
  34.     screen = numpy.array(screen)
  35.     print('Nympy take: {}'.format(time.time() - begin))
  36.     begin = time.time()
  37.     kick_ball(screen)
  38.     print('Process took: {}\n'.format(time.time() - begin))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement