Added Labyrinth. /JL

This commit is contained in:
Jan Lerking
2025-04-14 11:45:26 +02:00
parent 6914fd8632
commit b1701f02ea
3 changed files with 42 additions and 4 deletions

19
pman.py
View File

@@ -1,15 +1,18 @@
import pygame
from actors.enums import Colors, PlayerDirection
from actors.pacman import ActorPacman
from labyrinth import Labyrinth
__version__ = "0.1.0"
__version__ = "0.1.1"
def main() -> None:
pygame.init()
screen = pygame.display.set_mode((800, 800))
screen_width, screen_height = 800, 800
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Pac-Man " + __version__)
player = ActorPacman()
labyrinth = Labyrinth(screen, width=screen_width, height=screen_height)
player = ActorPacman(screen, center=(200, 200))
clock = pygame.time.Clock()
running = True
@@ -30,6 +33,16 @@ def main() -> None:
player.direction = PlayerDirection.DirectionUp
case pygame.K_DOWN:
player.direction = PlayerDirection.DirectionDown
case pygame.JOYHATMOTION:
hat_x, hat_y =event.value
if hat_x == 1:
player.direction = PlayerDirection.DirectionRight
elif hat_x == -1:
player.direction = PlayerDirection.DirectionLeft
elif hat_y == 1:
player.direction = PlayerDirection.DirectionUp
elif hat_y == -1:
player.direction = PlayerDirection.DirectionDown
player.animate()
player.draw()