""" Saudi eLeague Pac-Man | Renderer. Draws walls, lightning pellets, power bolts, the watermark banner, and the score / lives UI. """ import turtle from mazes import calculate_maze_data, maze_level_1 from constants import ( CELL_SIZE, SCREEN_HEIGHT, SCREEN_WIDTH, PELLET_SPRITE, POWER_SPRITE, BANNER_SPRITE, COLOR_WALL_FILL, COLOR_WALL_EDGE, COLOR_ACCENT_CYAN, COLOR_ACCENT_GREEN, COLOR_GOLD, COLOR_TEXT_PRIMARY, COLOR_TEXT_SECONDARY, ) class Pen(turtle.Turtle): def __init__(self): super().__init__() self.hideturtle() self.penup() self.speed(0) self.walls, self.pellets, self.power_pellets = calculate_maze_data( maze_level_1) class Wall(Pen): def __init__(self): super().__init__() self.shape("square") self.shapesize(1.2) self.pencolor(COLOR_WALL_EDGE) self.fillcolor(COLOR_WALL_FILL) def draw(self): for x, y in self.walls: self.goto(x, y) self.stamp() class Pellet(Pen): "Small cyan lightning bolts scattered through the maze." def __init__(self): super().__init__() turtle.register_shape(PELLET_SPRITE) self.shape(PELLET_SPRITE) self.stamps = {} def draw(self): for x, y in self.pellets: self.goto(x, y) stamp_id = self.stamp() self.stamps[(x, y)] = stamp_id class PowerPellet(Pen): "Larger green energy bolts — grant a speed boost." def __init__(self): super().__init__() turtle.register_shape(POWER_SPRITE) self.shape(POWER_SPRITE) self.stamps = {} def draw(self): for x, y in self.power_pellets: self.goto(x, y) stamp_id = self.stamp() self.stamps[(x, y)] = stamp_id class Banner(Pen): "Saudi eLeague watermark pinned to the top UI strip." def __init__(self): super().__init__() turtle.register_shape(BANNER_SPRITE) self.shape(BANNER_SPRITE) def draw(self): self.goto(0, SCREEN_HEIGHT / 2 - CELL_SIZE * 1.5) self.stamp() class UiPen(Pen): def __init__(self): super().__init__() self.color(COLOR_TEXT_PRIMARY) self.font_large = ("Courier", 22, "bold") self.font_small = ("Courier", 14, "bold") def draw_ui_area(self): "Thin cyan frame around the top HUD strip." self.pensize(2) self.pencolor(COLOR_ACCENT_CYAN) x = 0.98 * SCREEN_WIDTH / 2 top_y = 0.99 * SCREEN_HEIGHT / 2 bottom_y = top_y - 3 * CELL_SIZE self.penup() self.goto(x, top_y) self.pendown() self.goto(-x, top_y) self.goto(-x, bottom_y) self.goto(x, bottom_y) self.goto(x, top_y) self.penup() def write_score(self, score): self.clear() self.pencolor(COLOR_GOLD) self.goto(-0.92 * SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 2.1 * CELL_SIZE) self.write(f"SCORE {score}", False, "left", self.font_large) def write_lives(self, lives): self.clear() self.pencolor(COLOR_ACCENT_GREEN) self.goto(0.92 * SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 2.1 * CELL_SIZE) self.write(f"LIVES {lives}", False, "right", self.font_large) def write_message(self, msg, color=None): self.clear() if color: self.pencolor(color) self.goto(0, 0) self.write(msg, False, "center", ("Courier", 40, "bold"))