Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/helpers.py b/helpers.py
new file mode 100644
index 0000000..dd4ffff
--- /dev/null
+++ b/helpers.py
@@ -0,0 +1,20 @@
+#! /usr/bin/env python
+
+import os, sys
+import pygame
+from pygame.locals import *
+
+def load_image(name, colorkey=None):
+ fullname = os.path.join('data')
+ fullname = os.path.join(fullname, name)
+ try:
+ image = pygame.image.load(fullname)
+ except pygame.error, message:
+ print 'Cannot load image:', fullname
+ raise SystemExit, message
+ image = image.convert()
+ if colorkey is not None:
+ if colorkey is -1:
+ colorkey = image.get_at((0,0))
+ image.set_colorkey(colorkey, RLEACCEL)
+ return image, image.get_rect() \ No newline at end of file