aboutsummaryrefslogtreecommitdiff
path: root/src/game_state.py
diff options
context:
space:
mode:
authorMoisis <moisis.george@yahoo.com>2023-05-09 10:53:08 +0300
committerGitHub <noreply@github.com>2023-05-09 10:53:08 +0300
commit1c409760e93ce1641a7d1bcd5cd09a34ff86fe6b (patch)
treea1e9497fe359613f29164c589a499f727ef71d5c /src/game_state.py
parent1c33c06df4d40e708d526cd00d3b8392d931b7c2 (diff)
parent439ae67f933ee85bd425566cabac64815db4096e (diff)
downloadMacpan-1c409760e93ce1641a7d1bcd5cd09a34ff86fe6b.tar.xz
Macpan-1c409760e93ce1641a7d1bcd5cd09a34ff86fe6b.zip
Merge branch 'master' into TryatGUI
Diffstat (limited to 'src/game_state.py')
-rw-r--r--src/game_state.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/game_state.py b/src/game_state.py
new file mode 100644
index 0000000..5ed98c0
--- /dev/null
+++ b/src/game_state.py
@@ -0,0 +1,50 @@
+from blinky import Blinky
+from clyde import Clyde
+from inky import Inky
+from pinky import Pinky
+from player import Player
+from settings import settings
+import map as Map
+import pygame
+
+WIDTH = settings.width
+HEIGHT = settings.height
+maze = Map.Map()
+TILE_WIDTH = WIDTH // len(maze.maze[0])
+TILE_HEIGHT = HEIGHT // len(maze.maze)
+
+
+class GameState():
+ def __init__(self, sprites):
+ self.pacman = Player(sprites[0])
+ self.blinky = Blinky(sprites[1], 12 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.pinky = Pinky(sprites[2], 11 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.inky = Inky(sprites[3], 13 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.clyde = Clyde(sprites[4], 14 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.map = Map.Map()
+ self.food = 0
+ self.game_over = False
+ self.score = 0
+ self.is_pacman_alive = True
+
+ def reset(self, sprites):
+ self.pacman = Player(sprites[0])
+ self.blinky = Blinky(sprites[1], 12 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.pinky = Pinky(sprites[2], 11 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.inky = Inky(sprites[3], 13 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.clyde = Clyde(sprites[4], 14 * TILE_WIDTH +
+ 15, 12 * TILE_HEIGHT + 15)
+ self.map = Map.Map()
+ self.food = 0
+ self.game_over = False
+ self.is_pacman_alive = True
+ self.score = 0
+ timer_event = pygame.USEREVENT + 1
+ pygame.time.set_timer(timer_event, 1000 * 10, 1)