-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystemClassV2.py
99 lines (74 loc) · 3.29 KB
/
SystemClassV2.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
## SystemClass V2.0
import pygame
WHITE = 255, 255, 255
BLACK = 0, 0, 0
class TextButton(pygame.sprite.Sprite):
def __init__(self, screen, text, font, size, colorOff, colorOn, x, y):
pygame.sprite.Sprite.__init__(self)
self.font = pygame.font.Font(font, size)
self.textNormal = self.font.render(text, True, colorOff)
self.textHighlighted = self.font.render(text, True, colorOn)
self.screen = screen
self.pos = x, y
self.selected = False
def display(self):
if self.selected:
self.screen.blit(self.textHighlighted, self.pos)
else:
self.screen.blit(self.textNormal, self.pos)
class String(pygame.sprite.Sprite):
def __init__(self, screen, player, font, size, data, color,\
centerx, centery, twoParts = ''):
pygame.sprite.Sprite.__init__(self)
self.__screen = screen
self.__font = pygame.font.Font(font, size)
exec("self.data = player." + data)
if twoParts: self.image = self.__font.render(twoParts + str(self.data), True, color)
else: self.image = self.__font.render(str(self.data), True, color)
self.rect = self.image.get_rect()
self.rect.center = (centerx, centery)
def update(self):
data = self.__name__ + '()'
exec("self.data = player." + data)
try:
if twoParts: self.image = self.__font.render(twoParts + str(self.data), True, color)
else: self.image = self.__font.render(str(self.data), True, color)
except: pass
self.rect = self.image.get_rect()
self.rect.center = (centerx, centery)
class Icon(pygame.sprite.Sprite):
def __init__(self, screen, player, image_path, colorKey, \
centerx, centery, transformScale = None):
pygame.sprite.Sprite.__init__(self)
self.__screen = screen
try:
self.image = pygame.image.load(image_path).convert()
except:
exec('self.image = ' + image_path)
if transformScale:
self.image = pygame.transform.scale(self.image, transformScale)
self.image.set_colorkey(colorKey)
self.rect = self.image.get_rect()
self.rect.center = (centerx, centery)
class Background(pygame.sprite.Sprite):
def __init__(self, screen):
pygame.sprite.Sprite.__init__(self)
self.__screen = screen
self.image = pygame.image.load("./imgSource/System/inGame.png").convert()
self.rect = self.image.get_rect()
'''
class Conversation():
def __init__(self, character, text, category, returnVal = ''):
if category == 0:
print("<{}>: {}".format(character, text))
elif category == 1:
exec(returnVal +'= input("<{}>: {}".format(character, text))')
'''
class SubtitleText(pygame.sprite.Sprite):
def __init__(self, screen, character, text, centerx, centery):
pygame.sprite.Sprite.__init__(self)
self.__screen = screen
self.font = pygame.font.Font('./Font/PAPYRUS.TTF', 30)
self.image = self.font.render(character.name + text, True, BLACK)
self.rect = self.image.get_rect()
self.rect.center = (centerx, centery)