Working on rotation. /JL

This commit is contained in:
Jan Lerking
2025-04-23 13:45:29 +02:00
parent 68595b1455
commit dd99fcb633
6 changed files with 70 additions and 39 deletions

22
hud.py
View File

@@ -1,9 +1,10 @@
import pygame
import os
from globals import TILE_SIZE
from enums import BrickColor
class Hud:
def __init__(self, screen_width, screen_height, tile_size, font_size=36, highscore_file="highscore.txt"):
def __init__(self, screen_width, screen_height, font_size=36, highscore_file="highscore.txt"):
self.highscore_file = highscore_file
self.highscore = self.load_highscore()
@@ -11,7 +12,6 @@ class Hud:
self.color = BrickColor.Red.value
self.screen_width = screen_width
self.screen_height = screen_height
self.tile_size = tile_size
self.reset()
@@ -56,24 +56,24 @@ class Hud:
# Score (top-left)
score_text = self.font.render(f"Score:", True, self.color)
score = self.font.render(f"{self.score}", True, self.color)
screen.blit(score_text, (self.tile_size / 2, self.tile_size))
screen.blit(score,(self.tile_size / 2, self.tile_size + 24))
screen.blit(score_text, (TILE_SIZE / 2, TILE_SIZE))
screen.blit(score,(TILE_SIZE / 2, TILE_SIZE + 24))
lines_text = self.font.render(f"Lines:", True, self.color)
lines = self.font.render(f"{self.lines}", True, self.color)
screen.blit(lines_text, (self.tile_size / 2, self.tile_size * 2 + 24))
screen.blit(lines, (self.tile_size / 2, self.tile_size * 3))
screen.blit(lines_text, (TILE_SIZE / 2, TILE_SIZE * 2 + 24))
screen.blit(lines, (TILE_SIZE / 2, TILE_SIZE * 3))
level_text = self.font.render(f"Level:", True, self.color)
level = self.font.render(f"{self.level}", True, self.color)
screen.blit(level_text, (self.tile_size / 2, self.tile_size * 4))
screen.blit(level, (self.tile_size / 2, self.tile_size * 4 + 24))
screen.blit(level_text, (TILE_SIZE / 2, TILE_SIZE * 4))
screen.blit(level, (TILE_SIZE / 2, TILE_SIZE * 4 + 24))
# Highscore (top-center)
highscore_text = self.font.render(f"High Score:", True, self.color)
highscore = self.font.render(f"{self.highscore}", True, self.color)
screen.blit(highscore_text, (self.tile_size / 2, self.tile_size * 5 + 24))
screen.blit(highscore, (self.tile_size / 2, self.tile_size * 6))
screen.blit(highscore_text, (TILE_SIZE / 2, TILE_SIZE * 5 + 24))
screen.blit(highscore, (TILE_SIZE / 2, TILE_SIZE * 6))
next_text = self.font.render("Next:", True, self.color)
screen.blit(next_text, (self.tile_size * 15, self.tile_size))
screen.blit(next_text, (TILE_SIZE * 15, TILE_SIZE))