-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.py
34 lines (26 loc) · 894 Bytes
/
message.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
import pygame
class Message(pygame.sprite.Sprite):
def __init__(self, text, pos, color=(230, 230, 230)):
super().__init__()
font = pygame.font.SysFont('oldenglishtext', 25)
self.text = text
self.color = color
self.image = font.render(text, True, color)
self.rect = self.image.get_rect()
self.rect.center = pos
self.time = 0
def update(self):
self.time += 1
if self.time > 120:
self.kill()
def save(self):
self.image = None
def load(self):
font = pygame.font.SysFont('oldenglishtext', 25)
self.image = font.render(self.text, True, self.color)
class MovingMessage(Message):
def __init__(self, text, pos, color=(230, 230, 230)):
super().__init__(text, pos, color)
def update(self):
super().update()
self.rect.move_ip((0, -1))