update flappy
This commit is contained in:
18
flappy.py
18
flappy.py
@@ -18,11 +18,14 @@ 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
|
||||||
|
tmp = 20
|
||||||
|
self.click()
|
||||||
|
cv.waitKey(int(100))
|
||||||
|
if tmp % 5 == 0:
|
||||||
|
self.click()
|
||||||
|
cv.waitKey(int(wait_timer -100))
|
||||||
|
|
||||||
pydirectinput.mouseDown()
|
'''
|
||||||
cv.waitKey(50)
|
|
||||||
pydirectinput.mouseUp()
|
|
||||||
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
|
||||||
if offset > 50:
|
if offset > 50:
|
||||||
@@ -33,4 +36,9 @@ class Flappy(GameBase):
|
|||||||
wait_timer = 380 + offset
|
wait_timer = 380 + offset
|
||||||
print(wait_timer)
|
print(wait_timer)
|
||||||
print("pet_pos: ", self.flappy_pos_disc.current_pet_height)
|
print("pet_pos: ", self.flappy_pos_disc.current_pet_height)
|
||||||
print("next gate: ", self.flappy_pos_disc.next_gate_height[0] + 120)
|
print("next gate: ", self.flappy_pos_disc.next_gate_height[0] + 120) '''
|
||||||
|
|
||||||
|
def click(self):
|
||||||
|
pydirectinput.mouseDown()
|
||||||
|
cv.waitKey(50)
|
||||||
|
pydirectinput.mouseUp()
|
||||||
@@ -20,7 +20,7 @@ class FlappyPosDiscovery(threading.Thread):
|
|||||||
self.mask_g = self.scale_picture(cv.imread("flappy/gate-mask.png"), 50)
|
self.mask_g = self.scale_picture(cv.imread("flappy/gate-mask.png"), 50)
|
||||||
|
|
||||||
self.run_mode = 'run'
|
self.run_mode = 'run'
|
||||||
self.current_pet_height = 0
|
self.current_pet_height = []
|
||||||
self.next_gate_height = [0,0,0]
|
self.next_gate_height = [0,0,0]
|
||||||
|
|
||||||
self.offset_down = 90
|
self.offset_down = 90
|
||||||
@@ -51,7 +51,9 @@ class FlappyPosDiscovery(threading.Thread):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
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.append(rectangles_f[0][1] + rectangles_f[0][3] + self.offset_down)
|
||||||
|
if len(self.next_gate_height) > 5:
|
||||||
|
self.next_gate_height.pop(0)
|
||||||
|
|
||||||
#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)
|
||||||
@@ -68,7 +70,8 @@ class FlappyPosDiscovery(threading.Thread):
|
|||||||
return thresh
|
return thresh
|
||||||
|
|
||||||
def get_actual_pet_height(self):
|
def get_actual_pet_height(self):
|
||||||
return self.current_pet_height
|
return sum(self.current_pet_height) / len(self.current_pet_height)
|
||||||
|
|
||||||
|
|
||||||
def get_next_gate_height(self):
|
def get_next_gate_height(self):
|
||||||
return self.next_gate_height
|
return self.next_gate_height
|
||||||
|
|||||||
Reference in New Issue
Block a user