|
5 | 5 |
|
6 | 6 | import sys
|
7 | 7 | import time
|
8 |
| -import dxcam |
9 | 8 | import mouse
|
10 | 9 | import random
|
11 | 10 | import keyboard
|
12 | 11 | import datetime
|
| 12 | +# import dxcam_cpp as dxcam |
| 13 | +import dxcam |
| 14 | + |
| 15 | +from PIL import Image |
13 | 16 |
|
14 | 17 | from prepare_app import prepare_app
|
15 | 18 | from constants import (
|
@@ -46,6 +49,15 @@ def check_running(frame, application_bbox) -> bool:
|
46 | 49 | if frame[y][x][2] == APPLICATION_TRIGGER['color'][2]:
|
47 | 50 | return True
|
48 | 51 |
|
| 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 | + |
49 | 61 | return False
|
50 | 62 |
|
51 | 63 |
|
@@ -91,7 +103,13 @@ def wait_running_game(camera, timeout:float = .0) -> None:
|
91 | 103 | application_bbox = prepare_app()
|
92 | 104 | frame = camera.get_latest_frame()
|
93 | 105 | timer = time.time()
|
| 106 | + # _flag = True |
94 | 107 | 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 |
95 | 113 | application_bbox = prepare_app()
|
96 | 114 | frame = camera.get_latest_frame()
|
97 | 115 |
|
@@ -137,7 +155,7 @@ def main():
|
137 | 155 |
|
138 | 156 | __timer = datetime.datetime.now()
|
139 | 157 |
|
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): |
141 | 159 |
|
142 | 160 | for x in x_range:
|
143 | 161 | for y in y_range:
|
|
0 commit comments