Mercurial > rinkhals
comparison 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 |
comparison
equal
deleted
inserted
replaced
185:cef972d285f7 | 186:f06010d34cd3 |
---|---|
1 """In-game sprite cursors for the gameboard. | |
2 | |
3 Currently mostly used when placing buildings. | |
4 """ | |
5 | |
6 import imagecache | |
7 from pgu.vid import Sprite | |
8 | |
9 class SpriteCursor(Sprite): | |
10 """A Sprite used as an on-board cursor.""" | |
11 | |
12 def __init__(self, image_name, tv): | |
13 image = imagecache.load_image(image_name, ["sprite_cursor"]) | |
14 # Create the sprite somewhere far off screen | |
15 Sprite.__init__(self, image, (-1000, -1000)) | |
16 self._tv = tv | |
17 | |
18 def set_pos(self, tile_pos): | |
19 """Set the cursor position on the gameboard.""" | |
20 self.rect.x, self.rect.y = self._tv.tile_to_view(tile_pos) |