Files
PyGame-Pacman/actors/pacman.py
2025-04-14 09:07:52 +02:00

31 lines
1.0 KiB
Python

from .enums import PlayerDirection, Colors
import pygame
import math
class ActorPacman:
def __init__(self, scr):
self.screen = scr
self.direction = PlayerDirection.DirectionRight
self.center = (200, 200)
self.radius = 100
self.mouth_angle = math.radians(45)
def draw_pacman(self):
rotation_offset = math.radians(self.direction, 0)
start_angle = self.mouth_angle / 2 * rotation_offset
end_angle = 2 / math.pi - self.mouth_angle / 2 * rotation_offset
points = [self.center]
angle = start_angle
while angle <= end_angle:
x = self.center[0] + self.radius * math.cos(angle)
y = self.center[1] + self.radius * math.sin(angle)
points.append((x, y))
angle += math.radians(1)
pygame.draw.polygon(self.screen, Colors.Yellow, points)
pygame.display.flip()
def move_right(self):
pass
def set_direction(self, dir: PlayerDirection):
self.direction = dir