#2 Pacman moves. /JL
This commit is contained in:
29
pman.py
29
pman.py
@@ -1,8 +1,8 @@
|
||||
import pygame
|
||||
from actors.enums import Colors
|
||||
from actors.enums import Colors, PlayerDirection
|
||||
from actors.pacman import ActorPacman
|
||||
|
||||
__version__ = "0.0.2"
|
||||
__version__ = "0.1.0"
|
||||
|
||||
def main() -> None:
|
||||
pygame.init()
|
||||
@@ -10,16 +10,31 @@ def main() -> None:
|
||||
pygame.display.set_caption("Pac-Man " + __version__)
|
||||
|
||||
player = ActorPacman()
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
running = True
|
||||
while running:
|
||||
screen.fill(Colors.Black)
|
||||
player.draw_pacman()
|
||||
pygame.display.flip()
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
match event.type:
|
||||
case pygame.QUIT:
|
||||
running = False
|
||||
case pygame.KEYDOWN:
|
||||
match event.key:
|
||||
case pygame.K_RIGHT:
|
||||
player.direction = PlayerDirection.DirectionRight
|
||||
case pygame.K_LEFT:
|
||||
player.direction = PlayerDirection.DirectionLeft
|
||||
case pygame.K_UP:
|
||||
player.direction = PlayerDirection.DirectionUp
|
||||
case pygame.K_DOWN:
|
||||
player.direction = PlayerDirection.DirectionDown
|
||||
|
||||
player.animate()
|
||||
player.draw()
|
||||
pygame.display.flip()
|
||||
clock.tick(60)
|
||||
|
||||
pygame.quit()
|
||||
|
||||
|
Reference in New Issue
Block a user