-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
20 lines (16 loc) · 961 Bytes
/
utils.py
File metadata and controls
20 lines (16 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pygame
from constants import WHITE, FONT, SCREEN_HEIGHT, HUD_HEIGHT, GRAY
def draw_score_and_lives(screen, score, lives):
score_text = FONT.render(f'Score: {score}', True, WHITE)
lives_text = FONT.render(f'Lives: {lives}', True, WHITE)
screen.blit(score_text, (10, SCREEN_HEIGHT - HUD_HEIGHT + 10))
screen.blit(lives_text, (screen.get_width() - 100, SCREEN_HEIGHT - HUD_HEIGHT + 10))
def draw_game_over(screen):
game_over_text = FONT.render('Game Over! Press R to Restart', True, WHITE)
screen.blit(game_over_text, (screen.get_width() // 2 - game_over_text.get_width() // 2, screen.get_height() // 2))
def draw_bricks(screen, bricks):
for brick in bricks:
pygame.draw.rect(screen, brick['color'], brick['rect'])
pygame.draw.rect(screen, WHITE, brick['rect'], 2) # Outline
def draw_hud(screen):
pygame.draw.rect(screen, GRAY, pygame.Rect(0, SCREEN_HEIGHT - HUD_HEIGHT, screen.get_width(), HUD_HEIGHT))