-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore.py
36 lines (27 loc) · 957 Bytes
/
score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame as pg
import os
from pygame import Surface
from common import Global,ASSETS_DIR,FONTS_DIR
class Score:
def __init__(self, screen : Surface) -> None:
self.screen = screen
self.value = 0
self.food = pg.transform.scale(
pg.image.load(os.path.join(ASSETS_DIR, "food.png")), (Global.CELL_WIDTH * 1.25,Global.CELL_WIDTH * 1.25)
)
self.font = pg.font.Font(os.path.join(FONTS_DIR, "Atop-R99O3.ttf"), 30)
def draw(self):
rect = (
Global.OFFSET,
Global.OFFSET - Global.CELL_WIDTH - 10,
)
surface = self.font.render(f"Score : {self.value}", True, Global.TEXT_COLOR_1)
self.screen.blit(surface, rect)
w = surface.get_width()
rect = (
Global.OFFSET + w,
Global.OFFSET - Global.CELL_WIDTH - 12,
)
self.screen.blit(self.food, rect)
def update(self):
self.value += 1