@@ -15,6 +15,9 @@ class ActorPacman:
|
|||||||
self.animate_speed = 2
|
self.animate_speed = 2
|
||||||
self.mouth_closing = False
|
self.mouth_closing = False
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self.animate()
|
||||||
|
|
||||||
def animate(self):
|
def animate(self):
|
||||||
if self.mouth_closing:
|
if self.mouth_closing:
|
||||||
self.mouth_angle_deg -= self.animate_speed
|
self.mouth_angle_deg -= self.animate_speed
|
||||||
@@ -26,18 +29,18 @@ class ActorPacman:
|
|||||||
if self.mouth_angle_deg >= self.max_mouth_deg:
|
if self.mouth_angle_deg >= self.max_mouth_deg:
|
||||||
self.mouth_angle_deg = self.max_mouth_deg
|
self.mouth_angle_deg = self.max_mouth_deg
|
||||||
self.mouth_closing = True
|
self.mouth_closing = True
|
||||||
match self.direction:
|
match self.direction:
|
||||||
case PlayerDirection.DirectionRight:
|
case PlayerDirection.DirectionRight:
|
||||||
self.x += self.speed
|
self.x += self.speed
|
||||||
case PlayerDirection.DirectionLeft:
|
case PlayerDirection.DirectionLeft:
|
||||||
self.x -= self.speed
|
self.x -= self.speed
|
||||||
case PlayerDirection.DirectionUp:
|
case PlayerDirection.DirectionUp:
|
||||||
self.y -= self.speed
|
self.y -= self.speed
|
||||||
case PlayerDirection.DirectionDown:
|
case PlayerDirection.DirectionDown:
|
||||||
self.y += self.speed
|
self.y += self.speed
|
||||||
|
|
||||||
self.x = max(self.radius, min(self.x, 400 - self.radius))
|
self.x = max(self.radius, min(self.x, 400 - self.radius))
|
||||||
self.y = max(self.radius, min(self.y, 400 - self.radius))
|
self.y = max(self.radius, min(self.y, 400 - self.radius))
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
mouth_angle = math.radians(self.mouth_angle_deg)
|
mouth_angle = math.radians(self.mouth_angle_deg)
|
||||||
@@ -54,8 +57,5 @@ class ActorPacman:
|
|||||||
angle += math.radians(1)
|
angle += math.radians(1)
|
||||||
pygame.draw.polygon(self.screen, Colors.Yellow.value, points)
|
pygame.draw.polygon(self.screen, Colors.Yellow.value, points)
|
||||||
|
|
||||||
def move_right(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def set_direction(self, dir: PlayerDirection):
|
def set_direction(self, dir: PlayerDirection):
|
||||||
self.direction = dir
|
self.direction = dir
|
Reference in New Issue
Block a user