Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/kuku_utils.py
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2012-01-21 03:01:52 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2012-01-21 03:01:52 (GMT)
commit98f6174becbf79905bf8aa3e8c2d89ac2b494f3f (patch)
treeffdc45e9d43dd18f317498f8f622bec3b9c565d4 /kuku_utils.py
version 1v1
Diffstat (limited to 'kuku_utils.py')
-rw-r--r--kuku_utils.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/kuku_utils.py b/kuku_utils.py
new file mode 100644
index 0000000..ec46ee4
--- /dev/null
+++ b/kuku_utils.py
@@ -0,0 +1,27 @@
+import os
+import pygame
+from pygame.locals import *
+
+try:
+ from sugar.activity.activity import get_bundle_path
+except ImportError:
+ def get_bundle_path():
+ return ''
+
+def data_path(file_name):
+ return os.path.join(get_bundle_path(),'data',file_name)
+
+
+def load_image(file, transparent):
+ "loads an image, prepares it for play"
+ file = data_path(file)
+ try:
+ surface = pygame.image.load(file)
+ except pygame.error:
+ raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error())
+ if transparent:
+ corner = surface.get_at((0, 0))
+ surface.set_colorkey(corner, RLEACCEL)
+ return surface.convert()
+
+