Skip to content

Commit

Permalink
fixes v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Wokzy committed Sep 12, 2024
1 parent 528e1a1 commit eca43c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
PIXELS_PER_ITERATION = 10

NEW_GAME_TRIGGER_POS = (210/402, 615/712)
AVG_GAME_DURATION = 30 # seconds
16 changes: 12 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
import time
import dxcam
import mouse
import datetime

from prepare_app import prepare_app
from constants import APPLICATION_TRIGGER, COLOR_TRIGGERS, PIXELS_PER_ITERATION, \
NEW_GAME_TRIGGER_POS
from constants import (
APPLICATION_TRIGGER,
COLOR_TRIGGERS,
PIXELS_PER_ITERATION,
NEW_GAME_TRIGGER_POS,
AVG_GAME_DURATION,
)


__author__ = "Wokzy"
Expand Down Expand Up @@ -47,9 +53,9 @@ def check_object(pixel:tuple[int]) -> bool:


def wait_running_game(camera, timeout:float = .0) -> None:
application_bbox = prepare_app()
frame = camera.get_latest_frame()
timer = time.time()
application_bbox = prepare_app()
while not check_running(frame, application_bbox):
application_bbox = prepare_app()
frame = camera.get_latest_frame()
Expand Down Expand Up @@ -90,7 +96,9 @@ def main():
print(f'Game {game_counter} detected!')
frame = camera.get_latest_frame()

while check_running(frame, application_bbox):
__timer = datetime.datetime.now()

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

for x in x_range:
for y in y_range:
Expand Down

0 comments on commit eca43c2

Please sign in to comment.