Esempio n. 1
0
    def __render_start_and_finish_on(self, surface: Surface):
        start, finish = self.drone_controller.get_start_and_finish_coordinates()
        if start is None or finish is None:
            return

        render_image(surface, start, read_preferences().get_start_image())
        render_image(surface, finish, read_preferences().get_finish_image())
Esempio n. 2
0
    def __initialize_window(self):
        self.running = False
        init()

        display.set_icon(image.load(read_preferences().get_logo_image()))

        display.set_caption(read_preferences().get_title())
Esempio n. 3
0
    def render(self, color=Color.BLUE, background=Color.WHITE) -> Surface:
        width = read_preferences().get_width() * Dimension.BRICK_SIZE
        height = read_preferences().get_height() * Dimension.BRICK_SIZE

        surface = Surface((width, height))
        surface.fill(background)

        brick = Surface((Dimension.BRICK_SIZE, Dimension.BRICK_SIZE))
        brick.fill(color)

        for i in range(self.controller.get_height()):
            for j in range(self.controller.get_width()):
                if self.controller.is_wall(i, j):
                    surface.blit(
                        brick,
                        (j * Dimension.BRICK_SIZE, i * Dimension.BRICK_SIZE))

        return surface
Esempio n. 4
0
    def render_drone(self, algorithm: Algorithm) -> tuple[Surface, float]:
        should_continue = self.__choose_algorithm(algorithm)()

        surface, _ = self.render_path()

        drone_image = image.load(read_preferences().get_drone_image())
        x = self.drone_controller.get_drone_x()
        y = self.drone_controller.get_drone_y()

        surface.blit(drone_image, (y * Dimension.BRICK_SIZE, x * Dimension.BRICK_SIZE))

        return surface, should_continue
Esempio n. 5
0
    def __init__(self):
        height = read_preferences().get_height()
        width = read_preferences().get_width()

        self.__environment_model = EnvironmentModel(height, width)
Esempio n. 6
0
 def load_environment(self) -> EnvironmentModel:
     with open(read_preferences().get_map_file(), "rb") as file:
         self.__environment_model = pickle.load(file)
         return self.__environment_model
Esempio n. 7
0
 def save_environment(self):
     with open(read_preferences().get_map_file(), "wb") as file:
         pickle.dump(self.__environment_model, file)
Esempio n. 8
0
def get_random_range_by_height(height=read_preferences().get_height()):
    return randrange(height)
Esempio n. 9
0
def get_random_range_by_width(width=read_preferences().get_width()):
    return randrange(width)
Esempio n. 10
0
    def __draw_empty_screen(self):
        width = read_preferences().get_height() * Dimension.BRICK_SIZE
        height = read_preferences().get_width() * Dimension.BRICK_SIZE

        self.screen = display.set_mode((width, height))
        self.screen.fill(Color.WHITE)