diff options
| author | Omar Magdy <99906646+omagdy7@users.noreply.github.com> | 2023-04-16 17:50:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-16 17:50:36 +0200 |
| commit | b673be7fc9e94a5a8245797be6a62547c4efa579 (patch) | |
| tree | 5983f58f8512ca7386932a1549302d3e9fd7f3ba /src/Game.py | |
| parent | aa2162d1c2c873161b08efa3affff8ac73e27824 (diff) | |
| parent | 3634fcc4f9f62d40ea03ba890a3290e05ed20ed8 (diff) | |
| download | Macpan-b673be7fc9e94a5a8245797be6a62547c4efa579.tar.xz Macpan-b673be7fc9e94a5a8245797be6a62547c4efa579.zip | |
Merge pull request #4 from omagdy7/Ghost
Added Ghosts with A* implementation
Diffstat (limited to 'src/Game.py')
| -rw-r--r-- | src/Game.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/Game.py b/src/Game.py index 58b8987..e4784c9 100644 --- a/src/Game.py +++ b/src/Game.py @@ -1,5 +1,6 @@ from pygame.mouse import get_pressed import Player +import Ghost from Direction import DIRECTION import settings as Settings import map as Map @@ -24,6 +25,10 @@ class Game(): '../assets/pacman_left_sprite.png').convert_alpha() player = Player.Player(sprite_sheet) + blinky = Ghost.Ghost("red", 75, 75) + pinky = Ghost.Ghost("pink", 27 * 30, 30 * 30 + 15) + inky = Ghost.Ghost("orange", 75, 30 * 30 + 15) + clyde = Ghost.Ghost("cyan", 27 * 30 + 15, 75) # Set the pacman velocity dx = 0 @@ -41,6 +46,8 @@ class Game(): grid_x = Settings.settings.width // len(maze.maze[0]) grid_y = Settings.settings.height // len(maze.maze) + print(grid_x, grid_y) + # Checks collision with walls # checks if the current position of pacman is either a dot, big dot or free @@ -48,6 +55,8 @@ class Game(): is_dot = maze.maze[y][x] == Map.D is_big_dot = maze.maze[y][x] == Map.BD is_free = maze.maze[y][x] == 0 + if is_dot or is_big_dot: + maze.maze[y][x] = 0 return (is_dot or is_free or is_big_dot) @@ -66,11 +75,6 @@ class Game(): return True - - - - - # Main game loop running = True @@ -148,8 +152,16 @@ class Game(): player.y += dy + blinky.move(maze.maze, (player.x, player.y)) + pinky.move(maze.maze, (player.x, player.y)) + inky.move(maze.maze, (player.x, player.y)) + clyde.move(maze.maze, (player.x, player.y)) maze.draw_map(screen) player.draw(screen, counter) + blinky.draw(screen) + pinky.draw(screen) + inky.draw(screen) + clyde.draw(screen) # Update the screen pygame.display.flip() |
