Skip to content

Commit

Permalink
feat(fonts): add OpenSans-Medium.ttf font
Browse files Browse the repository at this point in the history
  • Loading branch information
alxdrcirilo committed Aug 14, 2023
1 parent 7302d6b commit 8cfccbb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ To evaluate the competitivity of the AI player (`WHITE`), 100 iterations of 100
The `BLACK` player always starts first and is the human player. The `WHITE` player starts second and is the AI player.

## Credits
### Assets
"Board Game Set - Checkers & Merels" [Game asset]. (n.d.). itch.io. Retrieved May 22, 2023, from https://mrserji.itch.io/board-game-set-checkers-merels

### Fonts
This project uses the [Open Sans](https://fonts.google.com/specimen/Open+Sans) font.
Binary file added assets/fonts/OpenSans-Medium.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion checkers/graphics/sprites/square.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _set_text(self, row: int, col: int) -> None:
:param int col: column position of the square
"""
color = WHITE if row % 2 != col % 2 else BLACK
self.font = pygame.font.SysFont("Arial", 9)
self.font = pygame.font.Font("assets/fonts/OpenSans-Medium.ttf", 9)
self.text_surface = self.font.render(f"{row},{col}", True, color)
self.image.blit(
self.text_surface,
Expand Down
6 changes: 3 additions & 3 deletions checkers/graphics/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _slide_piece(self, sprite: PieceSprite, move: tuple) -> None:

def display_winner(self) -> None:
# Text
font = pygame.font.SysFont("Arial", 24)
font = pygame.font.Font("assets/fonts/OpenSans-Medium.ttf", 24)
text = font.render(f"Winner: {self.game.winner}", True, WHITE)

# Rect
Expand All @@ -294,13 +294,13 @@ def display_winner(self) -> None:
self.screen.blit(text, (text_x, text_y))

# Turn text
font = pygame.font.SysFont("Arial", 20)
font = pygame.font.Font("assets/fonts/OpenSans-Medium.ttf", 20)
text = font.render(f"Turn: {self.game.turn}", True, WHITE)
text_x = rect.centerx - text.get_width() // 2
self.screen.blit(text, (text_x, text_y - 34))

# "Click anywhere to exit" text
font = pygame.font.SysFont("Arial", 12)
font = pygame.font.Font("assets/fonts/OpenSans-Medium.ttf", 12)
text = font.render(f"Press any keystroke to exit", True, WHITE)
text_x = rect.centerx - text.get_width() // 2
self.screen.blit(text, (text_x, text_y + 40))

0 comments on commit 8cfccbb

Please sign in to comment.