forked from quasar098/midi-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhiticon.py
30 lines (23 loc) · 883 Bytes
/
hiticon.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
from utils import *
import pygame
class HitLevel(Enum):
early = 0
good = 1
perfect = 2
late = 3
miss = 4
class HitIcon:
surfaces: dict[HitLevel, pygame.Surface] = {}
def __init__(self, lvl: HitLevel, pos: Union[tuple[int, int], list[int]]):
if len(HitIcon.surfaces) == 0:
for level in HitLevel:
HitIcon.surfaces[level] = pygame.image.load(f"./assets/{level.name}.png").convert_alpha()
self.pos = pos
self.lvl = lvl
self.age_left = 500
self.surf = HitIcon.surfaces[lvl].copy()
def draw(self, screen: pygame.Surface, camera):
self.age_left -= 500*Config.dt
self.surf.set_alpha(int(max(min(self.age_left, 255), 0)))
screen.blit(self.surf, camera.offset(self.surf.get_rect(center=self.pos)))
return self.age_left <= 0