flappy init
This commit is contained in:
@@ -18,10 +18,11 @@ class Flappy(GameBase):
|
|||||||
while True:
|
while True:
|
||||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||||
return
|
return
|
||||||
|
|
||||||
pydirectinput.mouseDown()
|
pydirectinput.mouseDown()
|
||||||
cv.waitKey(50)
|
cv.waitKey(50)
|
||||||
pydirectinput.mouseUp()
|
pydirectinput.mouseUp()
|
||||||
cv.waitKey(wait_timer)
|
cv.waitKey(int(wait_timer))
|
||||||
if self.flappy_pos_disc.next_gate_height[0] is not 0:
|
if self.flappy_pos_disc.next_gate_height[0] is not 0:
|
||||||
offset = (self.flappy_pos_disc.next_gate_height[0] + 120) - self.flappy_pos_disc.current_pet_height
|
offset = (self.flappy_pos_disc.next_gate_height[0] + 120) - self.flappy_pos_disc.current_pet_height
|
||||||
print(offset)
|
print(offset)
|
||||||
|
|||||||
@@ -32,15 +32,15 @@ class FlappyPosDiscovery(threading.Thread):
|
|||||||
screenshot_g = self.scale_picture(self.capture_window.get_screenshot_by_area([700, 1200, 1860, 90]), 50)
|
screenshot_g = self.scale_picture(self.capture_window.get_screenshot_by_area([700, 1200, 1860, 90]), 50)
|
||||||
screenshot_f = self.scale_picture(self.capture_window.get_screenshot_by_area([200, 1250, 610, 90]), 50)
|
screenshot_f = self.scale_picture(self.capture_window.get_screenshot_by_area([200, 1250, 610, 90]), 50)
|
||||||
|
|
||||||
#cv.imshow("screenshot_g", screenshot_g)
|
#cv.imshow("screenshot_g", screenshot_f)
|
||||||
#cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
|
|
||||||
rectangles_g = self.vision_stun.find(screenshot_g, self.needle_g, 0.95, 1)
|
rectangles_g = self.vision_stun.find(screenshot_g, self.needle_g, 0.8, 1)
|
||||||
rectangles_f = self.vision_stun.find(screenshot_f, self.needle_f, 0.97, 1, True, self.mask_f)
|
rectangles_f = self.vision_stun.find(screenshot_f, self.needle_f, 0.7, 1) #, True, self.mask_f)
|
||||||
|
|
||||||
if len(rectangles_g) is not 0:
|
if len(rectangles_g) is not 0:
|
||||||
height = rectangles_g[0][1] + rectangles_g[0][3] + (self.offset_down /2)
|
height = rectangles_g[0][1] + rectangles_g[0][3] + (self.offset_down /2)
|
||||||
if self.next_gate_height[0] is not height:
|
if self.next_gate_height[2] is not height:
|
||||||
self.next_gate_height.append(height)
|
self.next_gate_height.append(height)
|
||||||
if len(self.next_gate_height) > 3:
|
if len(self.next_gate_height) > 3:
|
||||||
self.next_gate_height.pop(0)
|
self.next_gate_height.pop(0)
|
||||||
@@ -53,13 +53,19 @@ class FlappyPosDiscovery(threading.Thread):
|
|||||||
if len(rectangles_f) is not 0:
|
if len(rectangles_f) is not 0:
|
||||||
self.current_pet_height = rectangles_f[0][1] + rectangles_f[0][3] + self.offset_down
|
self.current_pet_height = rectangles_f[0][1] + rectangles_f[0][3] + self.offset_down
|
||||||
|
|
||||||
print("pet_pos: ", self.current_pet_height)
|
#print("pet_pos: ", self.current_pet_height)
|
||||||
print("next gate: ", self.next_gate_height)
|
#print("next gate: ", self.next_gate_height)
|
||||||
|
|
||||||
def scale_picture(self, img, scale_percent):
|
def scale_picture(self, img, scale_percent):
|
||||||
width = int(img.shape[1] * scale_percent / 100)
|
width = int(img.shape[1] * scale_percent / 100)
|
||||||
height = int(img.shape[0] * scale_percent / 100)
|
height = int(img.shape[0] * scale_percent / 100)
|
||||||
return cv.resize(img, (width, height), interpolation=4)
|
|
||||||
|
resized_img = cv.resize(img, (width, height), interpolation=4)
|
||||||
|
|
||||||
|
gray = cv.cvtColor(resized_img, cv.COLOR_BGR2GRAY)
|
||||||
|
thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
||||||
|
|
||||||
|
return thresh
|
||||||
|
|
||||||
def get_actual_pet_height(self):
|
def get_actual_pet_height(self):
|
||||||
return self.current_pet_height
|
return self.current_pet_height
|
||||||
|
|||||||
Reference in New Issue
Block a user