Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/api/Globe.py
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2013-04-30 07:59:09 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2013-04-30 07:59:09 (GMT)
commit044cd047007c17c9efcd71d3c169df414014abbb (patch)
tree91890950486bcefef9ce5c81772e8d5bee43db90 /src/api/Globe.py
parent84bd43afa63791db59ae1b35cf95bec50811277c (diff)
add basic globe
Diffstat (limited to 'src/api/Globe.py')
-rw-r--r--src/api/Globe.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/api/Globe.py b/src/api/Globe.py
new file mode 100644
index 0000000..6f8effa
--- /dev/null
+++ b/src/api/Globe.py
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+
+import pygame
+import Image
+from api.Sprite import CSprite
+
+path = 'assets/images/dialog/'
+
+
+class Globe(CSprite):
+ """ a basic label
+ properties:
+ font: font to use
+ text: text to display
+ fgColor: foreground color
+ bgColor: background color
+ center: position of label's center
+ size: (width, height) of label
+ """
+
+ def __init__(self, size, fontName = "freesansbold.ttf"):
+ CSprite.__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)
+ down_left = Image.loadImage(path + 'esquina-down-left.png')
+ down_right = Image.loadImage(path + 'esquina-down-right.png', False)
+ up = Image.loadImage(path + 'borde-sin-sombra.png')
+ down = Image.loadImage(path + 'borde-con-sombra.png')
+ center = Image.loadImage(path + 'fondo.png')
+
+
+ horizontal = (h - 68) / 34
+ vertical = (v - 68) / 34
+ horizontal = horizontal + 2
+ vertical = vertical + 2
+ h = horizontal * 34
+ v = vertical * 34
+
+ self.image = pygame.Surface((h, v))
+ self.image.fill((255,255,255))
+
+ for i in range(horizontal):
+ for j in range(vertical):
+ x = i * 34
+ y = j * 34
+ if (i == 0) and (j == 0):
+ self.image.blit(up_left, (x, y))
+ elif (i == 0) and (j==(vertical - 1)):
+ self.image.blit(down_left, (x, y))
+ elif (i == (horizontal - 1)) and (j == 0):
+ self.image.blit(up_right, (x, y))
+ elif (i == (horizontal - 1)) and (j == (vertical - 1)):
+ self.image.blit(down_right, (x, y))
+ else:
+ self.image.blit(center, (x, y))
+
+ #self.image = pygame.Surface((34, 34))
+ #self.image.blit(down_right, (0, 0))
+ self.image.set_colorkey((255,255,255))
+ #self.image = self.image.convert_alpha((255, 255, 255))
+ #self.text = ""
+ """self.fgColor = ((0x00, 0x00, 0x00))
+ self.bgColor = ((0xFF, 0xFF, 0xFF))"""
+ self.center = (200, 200)
+ self.size = (34, 34)
+
+ def set_center(self, aCenter):
+ self.center = aCenter
+
+ def set_size(self, aSize):
+ self.size = aSize
+ self._update_image()
+
+ def set_fgColor(self, afgColor):
+ self.fgColor = afgColor
+ self._update_image()
+
+ def set_bgColor(self, abgColor):
+ self.bgColor = abgColor
+ self._update_image()
+
+ def set_text(self, aText):
+ self.text = aText
+ self._update_image()
+
+ def _update_image(self):
+ self.image = pygame.Surface(self.size)
+ self.image.fill(self.bgColor)
+ fontSurface = self.font.render(self.text, True, self.fgColor, self.bgColor)
+ #center the text
+ xPos = (self.image.get_width() - fontSurface.get_width())/2
+ self.image.blit(fontSurface, (xPos, 0))
+
+ def update(self):
+ self.rect = self.image.get_rect()
+ self.rect.center = self.center
+ \ No newline at end of file