-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
39 lines (32 loc) · 1.01 KB
/
utils.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
37
38
39
import pygame as pg
import math
class Spritesheet:
"""
Class responsible for:
-retrieving spritesheet image from directories
"""
def __init__(self, filename):
self.spritesheet = pg.image.load(filename).convert()
def get_image(self,x,y,width, height):
image = pg.Surface((width, height))
image.blit(self.spritesheet, (0,0), (x,y,width,height))
return image
def format_time(delayed_time:int) -> int:
"""
Function responsible for:
-formating timer in the navbar
"""
minutes = delayed_time // 60
seconds = delayed_time % 60
if minutes < 10:
minutes_str = f"0{minutes}"
else:
minutes_str = str(minutes)
if seconds < 10:
seconds_str = f"0{seconds}"
else:
seconds_str = str(seconds)
if minutes > 0:
return f"{seconds_str}:{minutes_str}"
else:
return f"{seconds_str}:00"