Updated. /JL

This commit is contained in:
2025-04-21 13:56:21 +02:00
parent 4ebb3ad67f
commit 83b06994ce

39
pman.py
View File

@@ -165,29 +165,26 @@ class Game:
self.player.direction = PlayerDirection.DirectionRight self.player.direction = PlayerDirection.DirectionRight
self.player.move_right() self.player.move_right()
elif self.hat_x == -1: elif self.hat_x == -1:
if event.type == pygame.USEREVENT and event.dict.get("type_name") == "JOYHATREPEAT": if self.maze.is_wall(self.player.location[0] - 1, self.player.location[1]):
if self.maze.is_wall(self.player.location[0] - 1, self.player.location[1]): break
break elif self.maze.is_ghost_home(self.player.location[0] - 1, self.player.location[1]):
elif self.maze.is_ghost_home(self.player.location[0] - 1, self.player.location[1]): break
break self.player.direction = PlayerDirection.DirectionLeft
self.player.direction = PlayerDirection.DirectionLeft self.player.move_left()
self.player.move_left()
elif self.hat_y == 1: elif self.hat_y == 1:
if event.type == pygame.USEREVENT and event.dict.get("type_name") == "JOYHATREPEAT": if self.maze.is_wall(self.player.location[0], self.player.location[1] - 1):
if self.maze.is_wall(self.player.location[0], self.player.location[1] - 1): break
break elif self.maze.is_ghost_home(self.player.location[0], self.player.location[1] - 1):
elif self.maze.is_ghost_home(self.player.location[0], self.player.location[1] - 1): break
break self.player.direction = PlayerDirection.DirectionUp
self.player.direction = PlayerDirection.DirectionUp self.player.move_up()
self.player.move_up()
elif self.hat_y == -1: elif self.hat_y == -1:
if event.type == pygame.USEREVENT and event.dict.get("type_name") == "JOYHATREPEAT": if self.maze.is_wall(self.player.location[0], self.player.location[1] + 1):
if self.maze.is_wall(self.player.location[0], self.player.location[1] + 1): break
break elif self.maze.is_ghost_home(self.player.location[0], self.player.location[1] + 1):
elif self.maze.is_ghost_home(self.player.location[0], self.player.location[1] + 1): break
break self.player.direction = PlayerDirection.DirectionDown
self.player.direction = PlayerDirection.DirectionDown self.player.move_down()
self.player.move_down()
case pygame.USEREVENT: case pygame.USEREVENT:
if event.dict.get("type_name") == "JOYHATREPEAT": if event.dict.get("type_name") == "JOYHATREPEAT":