forked from MaxwellSalmon/DUGA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEXT.py
28 lines (22 loc) · 810 Bytes
/
TEXT.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
import pygame
pygame.font.init()
class Text:
def __init__(self, posx, posy, string, color, font, size):
self.posx = posx
self.posy = posy
self.string = string
self.color = color
self.size = size
self.font = pygame.font.Font(font, self.size)
self.layout = self.font.render(self.string, True, self.color)
def draw(self, canvas):
#Draw the text - Call each frame.
canvas.blit(self.layout,(self.posx, self.posy))
def update_string(self, string):
#Update the string that will be shown if needed.
self.layout = self.font.render(string, True, self.color)
self.string = string
def update_pos(self, x, y):
#Updates the position of the text.
self.posx = x
self.posy = y