flappy init

This commit is contained in:
2023-07-28 13:13:20 +02:00
parent c43399ac2a
commit bfd8690535
4 changed files with 34 additions and 66 deletions

View File

@@ -1,12 +1,6 @@
import cv2 as cv
import numpy as np
from time import time
import pydirectinput
from game_base_class import GameBase
from pynput.keyboard import Key, Controller
from flappy_pos_discovery_thread import FlappyPosDiscovery
class Flappy(GameBase):
@@ -14,24 +8,10 @@ class Flappy(GameBase):
def __init__(self, overlay):
super().__init__(overlay)
self.keyboard = Controller()
self.data_coordinates = np.zeros((20, 20), dtype=object)
self.observation = np.zeros((20, 20), dtype=int)
self.colors = [1, 2, 3, 4, 5, 6, 7, 8, 9]
self.offset_left = 610
self.offset_down = 40
self.fill_data_coordinates()
self.litris_reset_board = cv.imread("control_elements/sodoku_reset_button.jpg", cv.IMREAD_COLOR)
self.flappy_pos_disc = FlappyPosDiscovery()
self.move_mode = 1
def assess_playfield_and_make_move(self):
#last_letter_received = time()
wait_timer = 380
@@ -42,37 +22,5 @@ class Flappy(GameBase):
cv.waitKey(50)
pydirectinput.mouseUp()
cv.waitKey(wait_timer)
offset = (self.flappy_pos_disc.next_gate_height + 170) - self.flappy_pos_disc.current_pet_height
if offset < -100:
#pet go down
wait_timer = 430
elif 0 > offset > -100:
wait_timer = 405
elif 0 < offset < 50:
wait_timer = 355
elif offset > 50:
wait_timer = 330
'''
if self.stone_id_thread.get_pick_up_status() == False:
if (time() - last_letter_received) >= 5:
self.field.reset_field()
self.field.cleared_rows = 1
last_letter_received = time()
self.dig_point(1500, 980, 100)
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
return
continue
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
return
cv.waitKey(50)
continue
self.stone_id_thread.set_pick_up_status(False)
'''
if self.flappy_pos_disc.next_gate_height[0] is not 0:
wait_timer = wait_timer + (self.flappy_pos_disc.next_gate_height[0] + 120) - self.flappy_pos_disc.current_pet_height