Add scoreboard.py
This commit is contained in:
18
scoreboard.py
Normal file
18
scoreboard.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Scoreboard:
|
||||||
|
def __init__(self, font_size=24):
|
||||||
|
self.score = 0
|
||||||
|
self.font = pygame.font.Font(None, font_size)
|
||||||
|
self.color = (255, 255, 255)
|
||||||
|
self.position = (10, 10)
|
||||||
|
|
||||||
|
def add_points(self, points):
|
||||||
|
self.score += points
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.score = 0
|
||||||
|
|
||||||
|
def draw(self, screen):
|
||||||
|
score_text = self.font.render(f"Score: {self.score}", True, self.color)
|
||||||
|
screen.blit(score_text, self.position)
|
Reference in New Issue
Block a user