diff --git a/flappy.py b/flappy.py index 7c78e8d..8cf9df2 100644 --- a/flappy.py +++ b/flappy.py @@ -37,10 +37,10 @@ class Flappy(GameBase): while True: if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused': return - #pydirectinput.mouseDown() - #cv.waitKey(50) - #pydirectinput.mouseUp() - #cv.waitKey(250) + pydirectinput.mouseDown() + cv.waitKey(50) + pydirectinput.mouseUp() + cv.waitKey(250) ''' if self.stone_id_thread.get_pick_up_status() == False: if (time() - last_letter_received) >= 5: diff --git a/flappy_pos_discovery_thread.py b/flappy_pos_discovery_thread.py index 3eed375..b31c225 100644 --- a/flappy_pos_discovery_thread.py +++ b/flappy_pos_discovery_thread.py @@ -1,6 +1,5 @@ import threading import cv2 as cv -import numpy as np from window_capture import WindowCapture from vision import Vision from config_file import UserConfigs @@ -24,39 +23,33 @@ class FlappyPosDiscovery(threading.Thread): self.current_pet_height = 0 self.next_gate_height = 0 + self.offset_down = 90 + self.start() def run(self): while self.run_mode == 'run': - self.position_detection() - print("pet_pos: ", self.current_pet_height) - print("next gate: ", self.next_gate_height) + screenshot_g = self.capture_window.get_screenshot_by_area([1600, 1200, 800, 90]) + screenshot_f = self.capture_window.get_screenshot_by_area([200, 1250, 610, 90]) + rectangles_g = self.vision_stun.find(screenshot_g, self.needle_g, 0.97, 5, True, self.mask_g) + rectangles_f = self.vision_stun.find(screenshot_f, self.needle_f, 0.97, 1, True, self.mask_f) + + if len(rectangles_g) is not 0: + self.next_gate_height = rectangles_g[0][1] + rectangles_g[0][3] + self.offset_down + + if len(rectangles_f) is not 0: + self.current_pet_height = rectangles_f[0][1] + rectangles_f[0][3] + self.offset_down + + #print("pet_pos: ", self.current_pet_height) + #print("next gate: ", self.next_gate_height) def get_actual_pet_height(self): return self.current_pet_height def get_next_gate_height(self): return self.next_gate_height - def callback(self): - pass - - def destroy(self): - self.destroy() - - def get_run_mode(self): - return self.run_mode - def position_detection(self): - - screenshot = self.capture_window.get_screenshot() - #screenshot = screenshot[580:845, 1148:1412] - - rectangles_g = self.vision_stun.find(screenshot, self.needle_g, 0.9, 5, True, self.mask_g) - rectangles_f = self.vision_stun.find(screenshot, self.needle_f, 0.9, 1, True, self.mask_f) - if len(rectangles_g) == 0 or len(rectangles_f) == 0: - return None - self.current_pet_height = rectangles_f[1] + rectangles_f[3] - self.next_gate_height = rectangles_g[1] + rectangles_g[3] - # return pet height and next gate height + +