-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (62 loc) · 2.05 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import numpy as np
from PIL import ImageGrab
import cv2
from directKeys import click, queryMousePosition
import time
# changes per cycle
# click(1800, 10)
# time.sleep(1)
# gameCoords = [657, 232, 1262, 1039]
gameCoords = [656, 32, 1222, 1037]
smallerGameCoords = [657, 800, 1262, 802]
score = 0
previousLane = -1
def clickOnFirstBlock(screen):
global gameCoords, score, previousLane
for y_ in range(5, len(screen) - 5, 5):
for i in range(4):
if previousLane == i:
continue
w = gameCoords[2] - gameCoords[0]
x = i * w / 4 + w / 8
y = len(screen) - y_
if screen[y][x] < 40:
actualX = x + gameCoords[0]
actualY = y + gameCoords[1]
score += 1
if score > 1000:
actualY += 10
if score > 1250:
actualY += 10
if score > 1450:
actualY += 10
if score > 1600:
actualY += 20
for k in range(1700, 2500):
if score > k:
actualY += 10
else:
break
click(actualX, actualY)
previousLane = i
return
# previousLane = -1
while True:
mousePos = queryMousePosition()
if mousePos.x < 0:
break
while True:
mousePos = queryMousePosition()
if gameCoords[2] > mousePos.x > gameCoords[0]:
startTime = time.time()
screen = np.array(ImageGrab.grab(bbox=gameCoords))
screen = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
clickOnFirstBlock(screen)
print("Frame took {} seconds. Up to frame no {}".format((time.time() - startTime), "FUCK YOU"))
else:
if mousePos.x < 0:
score = 0
while True:
mousePos = queryMousePosition()
if gameCoords[2] < mousePos.x:
break