diff options
| author | Moisis <moisis.george@yahoo.com> | 2023-05-19 23:40:23 +0300 |
|---|---|---|
| committer | Moisis <moisis.george@yahoo.com> | 2023-05-19 23:40:23 +0300 |
| commit | 6a351ed2d6a554ed6d338abba234527705d1040f (patch) | |
| tree | a0475e1d88be01716e76f2e75c495a4284290bb9 /src/game.py | |
| parent | 0889aaf69cc0d4ca32ce66e000e827bddf6bd162 (diff) | |
| download | Macpan-6a351ed2d6a554ed6d338abba234527705d1040f.tar.xz Macpan-6a351ed2d6a554ed6d338abba234527705d1040f.zip | |
Final Touches #2
Diffstat (limited to 'src/game.py')
| -rw-r--r-- | src/game.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/game.py b/src/game.py index e211da7..8872c0c 100644 --- a/src/game.py +++ b/src/game.py @@ -14,10 +14,9 @@ class Game(): def __init__(self, lolsettings): self.settings = lolsettings - def show_gameover_screen(self, screen, game_state, sprites): font = pygame.font.SysFont(None, 64) - self.score(screen, game_state.score , 200 , 800) + self.score(screen, game_state.score, 200, 800) # Render the "Game Over" text to a surface game_over_text_1 = font.render( "Game Over", True, (255, 255, 255)) @@ -57,12 +56,11 @@ class Game(): quit_game = True # Set the flag to True to break out of both loops break - - def score(self, screen, text , POS1, POS2 ): - font = pygame.font.SysFont(None, 21) + def score(self, screen, text, POS1, POS2): + font = pygame.font.Font('../assets/PressStart2P-Regular.ttf', 21) wining_text_123 = font.render( - "Score", True, (255, 255, 255)) + "Score", True, (255, 255, 255)) # Render the "Game Over" text to a surface wining_text_12 = font.render( @@ -73,8 +71,7 @@ class Game(): center=(POS1 / 2, POS2 / 2)) text_rect_123 = wining_text_123.get_rect( - center=(POS1 / 2,( (POS2 / 2)-50) )) - + center=(POS1 / 2, ((POS2 / 2) - 50))) screen.blit(wining_text_12, text_rect_12) screen.blit(wining_text_123, text_rect_123) @@ -92,7 +89,6 @@ class Game(): wining_text_2 = font.render( "Press R to play again or Q to quit", True, (255, 255, 255)) - # Blit the "Game Over" text onto the screen text_rect_1 = wining_text_1.get_rect( center=(WIDTH / 2, HEIGHT / 2)) @@ -126,7 +122,7 @@ class Game(): break def reset_game(self, game_state, sprites): - game_state.reset(sprites,self.settings) + game_state.reset(sprites, self.settings) def run(self): # Initialize Pygame @@ -154,7 +150,7 @@ class Game(): pygame.time.set_timer(timer_event, 1000 * 10, 1) game_state = GameState(sprites, self.settings) - self.score(screen,game_state.score,WIDTH,HEIGHT) + # self.score(screen,game_state.score,WIDTH,HEIGHT) # Set the pacman velocity dx = 0 @@ -168,7 +164,6 @@ class Game(): pygame.mixer.music.load('../assets/sfx/game_start.wav') siren_sound = pygame.mixer.Sound('../assets/sfx/siren_1.wav') - if self.settings.sound: pygame.mixer.music.play() siren_sound.play(-1) @@ -178,7 +173,8 @@ class Game(): # setting game fps clock.tick(settings.fps) - self.score(screen, game_state.score,WIDTH,HEIGHT) + # self.score(screen, game_state.score,WIDTH,HEIGHT) + # counter logic for cycling between pacman different sprites if counter < 19: counter += 1 @@ -186,7 +182,6 @@ class Game(): else: counter = 0 - screen.fill((0, 0, 0)) # Clear the screen # Temporary values for delta_x and delta_y in the position of pacman @@ -292,6 +287,7 @@ class Game(): game_state.is_pacman_alive = True else: + self.score(screen, game_state.score, WIDTH, HEIGHT) # Update the screen pygame.display.flip() |
