Skip to content

Commit 2fb5945

Browse files
committed
minor changes v2
1 parent ed809c5 commit 2fb5945

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"green":{"min":220, "max":255},
2121
"blue":{"min":5, "max":55}}
2222
APPLICATION_TRIGGER = {"color":(234, 212, 12), "positions":[(60/402, 112/712), (43/402, 110/712),
23-
(102/402, 113/712), (61/402, 106/712)]}
23+
(102/402, 113/712), (61/402, 106/712)],
24+
"range":(range(35, 116, 5), range(100, 125, 5))}
2425
PIXELS_PER_ITERATION = 10
2526

2627
NEW_GAME_TRIGGER_POS = (210/402, 615/712)

main.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55

66
import sys
77
import time
8-
import dxcam
98
import mouse
109
import random
1110
import keyboard
1211
import datetime
12+
# import dxcam_cpp as dxcam
13+
import dxcam
14+
15+
from PIL import Image
1316

1417
from prepare_app import prepare_app
1518
from constants import (
@@ -46,6 +49,15 @@ def check_running(frame, application_bbox) -> bool:
4649
if frame[y][x][2] == APPLICATION_TRIGGER['color'][2]:
4750
return True
4851

52+
for x in APPLICATION_TRIGGER['range'][0]:
53+
x += application_bbox[0]
54+
for y in APPLICATION_TRIGGER['range'][1]:
55+
y += application_bbox[1]
56+
if frame[y][x][0] == APPLICATION_TRIGGER['color'][0]:
57+
if frame[y][x][1] == APPLICATION_TRIGGER['color'][1]:
58+
if frame[y][x][2] == APPLICATION_TRIGGER['color'][2]:
59+
return True
60+
4961
return False
5062

5163

@@ -91,7 +103,13 @@ def wait_running_game(camera, timeout:float = .0) -> None:
91103
application_bbox = prepare_app()
92104
frame = camera.get_latest_frame()
93105
timer = time.time()
106+
# _flag = True
94107
while not check_running(frame, application_bbox):
108+
# if frame.any() and _flag:
109+
# print(frame)
110+
# # img = Image.fromarray(frame)
111+
# # img.save('poo3.png')
112+
# flag = False
95113
application_bbox = prepare_app()
96114
frame = camera.get_latest_frame()
97115

@@ -137,7 +155,7 @@ def main():
137155

138156
__timer = datetime.datetime.now()
139157

140-
while check_running(frame, application_bbox) or (datetime.datetime.now() - __timer).total_seconds() < AVG_GAME_DURATION:
158+
while (datetime.datetime.now() - __timer).total_seconds() < AVG_GAME_DURATION or check_running(frame, application_bbox):
141159

142160
for x in x_range:
143161
for y in y_range:

0 commit comments

Comments
 (0)