forked from dciets/Arcade-CS-Games
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfx.py
More file actions
24 lines (19 loc) · 657 Bytes
/
gfx.py
File metadata and controls
24 lines (19 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
WHITE = (255,255,255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
class Gfx:
"""Helper class to easily print text and draw stuff"""
def __init__(self, screen, font):
self.screen = screen
self.font = font
def print_msg(self, msg, topleft=None, topright=None, midtop=None, color=WHITE):
msg_sf = self.font.render(msg, 0, color)
rect = msg_sf.get_rect()
if topleft is not None:
rect.topleft = topleft
elif topright is not None:
rect.topright = topright
elif midtop is not None:
rect.midtop = midtop
self.screen.blit(msg_sf, rect)