diff gamelib/cursor.py @ 302:6d93e04036c9

CursorSprite: Default pointer-position to the centre of the cursor
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 28 Aug 2010 01:32:54 +0200
parents fbfd8e748ac0
children 3476e8f3b100
line wrap: on
line diff
--- a/gamelib/cursor.py	Sat Aug 28 01:22:44 2010 +0200
+++ b/gamelib/cursor.py	Sat Aug 28 01:32:54 2010 +0200
@@ -13,7 +13,7 @@
 class CursorSprite(Sprite):
     "A Sprite that follows the Cursor"
 
-    def __init__(self, filename, x, y):
+    def __init__(self, filename, x=None, y=None):
         Sprite.__init__(self)
         self.filename = filename
         self.pointer_x = x
@@ -25,6 +25,12 @@
             self.plain_image = get_image('items', self.filename)
             self.image = self.plain_image
             self.rect = self.image.get_rect()
+
+            if self.pointer_x is None:
+                self.pointer_x = self.rect.size[0] // 2
+            if self.pointer_y is None:
+                self.pointer_y = self.rect.size[1] // 2
+
             self.highlight = pygame.Surface(self.rect.size)
             color = pygame.color.Color(255, 100, 100, 0)
             self.highlight.fill(color)