Mercurial > rinkhals
diff gamelib/sprite_cursor.py @ 186:f06010d34cd3
Add sprite cursors for building placement.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 17:49:37 +0000 |
parents | |
children | 0bd214cf9018 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/sprite_cursor.py Fri Sep 04 17:49:37 2009 +0000 @@ -0,0 +1,20 @@ +"""In-game sprite cursors for the gameboard. + + Currently mostly used when placing buildings. + """ + +import imagecache +from pgu.vid import Sprite + +class SpriteCursor(Sprite): + """A Sprite used as an on-board cursor.""" + + def __init__(self, image_name, tv): + image = imagecache.load_image(image_name, ["sprite_cursor"]) + # Create the sprite somewhere far off screen + Sprite.__init__(self, image, (-1000, -1000)) + self._tv = tv + + def set_pos(self, tile_pos): + """Set the cursor position on the gameboard.""" + self.rect.x, self.rect.y = self._tv.tile_to_view(tile_pos)