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())
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())
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
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
def __init__(self): height = read_preferences().get_height() width = read_preferences().get_width() self.__environment_model = EnvironmentModel(height, width)
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
def save_environment(self): with open(read_preferences().get_map_file(), "wb") as file: pickle.dump(self.__environment_model, file)
def get_random_range_by_height(height=read_preferences().get_height()): return randrange(height)
def get_random_range_by_width(width=read_preferences().get_width()): return randrange(width)
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)