diff options
author | Alan Aguiar <alanjas@hotmail.com> | 2013-04-30 09:00:23 (GMT) |
---|---|---|
committer | Alan Aguiar <alanjas@hotmail.com> | 2013-04-30 09:00:23 (GMT) |
commit | 9243fe12f7ffa866b25e41cd28a45b40f59eab4b (patch) | |
tree | 06c9c487b6234c0ab83ce98c1d0ab24836c0fb08 /src/api/Globe.py | |
parent | c0998b265d53f5f5f244a18749a8b942fc958fd3 (diff) |
add basic text function for globe
Diffstat (limited to 'src/api/Globe.py')
-rw-r--r-- | src/api/Globe.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/api/Globe.py b/src/api/Globe.py index e6e1e28..6ab6bee 100644 --- a/src/api/Globe.py +++ b/src/api/Globe.py @@ -7,7 +7,7 @@ from api.Sprite import CSprite path = 'assets/images/dialog/' -class Globe(CSprite): +class Globe(pygame.sprite.Sprite): """ a basic label properties: font: font to use @@ -18,22 +18,23 @@ class Globe(CSprite): size: (width, height) of label """ - def __init__(self, size, fontName = "freesansbold.ttf"): - CSprite.__init__(self) - #self.font = pygame.font.Font(fontName, 20) + def __init__(self, size, text = '', fontName = "freesansbold.ttf"): + pygame.sprite.Sprite.__init__(self) + self.font = pygame.font.Font(fontName, 20) h = size[0] v = size[1] - #up_left = Image.loadImage(path + 'esquina-up-left.png', False) - up_left = pygame.image.load(path + 'esquina-up-left.png') - up_right = Image.loadImage(path + 'esquina-up-right.png', True) + + up_left = Image.loadImage(path + 'esquina-up-left.png') + up_right = Image.loadImage(path + 'esquina-up-right.png') down_left = Image.loadImage(path + 'esquina-down-left.png') - down_right = Image.loadImage(path + 'esquina-down-right.png', False) + down_right = Image.loadImage(path + 'esquina-down-right.png') up = Image.loadImage(path + 'borde-sin-sombra.png') down = Image.loadImage(path + 'borde-con-sombra.png') center = Image.loadImage(path + 'fondo.png') left = pygame.transform.rotate(up, 90) right = pygame.transform.rotate(down, 90) pico_der = Image.loadImage(path + 'pico-der.png') + pico_izq = Image.loadImage(path + 'pico-izq.png') horizontal = (h - 68) / 34 vertical = (v - 68) / 34 @@ -85,6 +86,18 @@ class Globe(CSprite): self.center = (200, 200) self.size = (34, 34) + self.text = text + x = h / 2 + y = 25 + lines = self.text.split("\n") + for l in lines: + text = self.font.render(l.strip(), 1, (0, 0, 0)) + textrect = text.get_rect() + textrect.center = (x,y) + self.image.blit(text, textrect) + y = y + self.font.get_height() + 15 + + def set_center(self, aCenter): self.center = aCenter |