Skip to content

Commit

Permalink
perfectly centred the game over text
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico committed Jun 15, 2023
1 parent 0888b1a commit 383f436
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dodgy_square/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ def detect_collision(self, player_pos: list[int], enemy_pos: list[int]) -> bool:
def show_game_over(self):
"""Display game-over text"""

# Create the text
game_over_text = self.font.render('Game Over', True, self.WHITE)
self.screen.blit(game_over_text, (self.screen_width // 2 - 70, self.screen_height // 2 - 16))

# Make sure the text is centred
text_width, text_height = game_over_text.get_size()
coordinates: tuple = (self.screen_width // 2 - text_width // 2, self.screen_height // 2 - text_height // 2)
self.screen.blit(game_over_text, coordinates)

# Replay the game
def replay_game(self):
Expand Down

0 comments on commit 383f436

Please sign in to comment.