Mercurial > rinkhals
comparison gamelib/buildings.py @ 43:fb5be14ea930
Start of building sprites.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Mon, 31 Aug 2009 16:49:12 +0000 |
parents | |
children | 08665fa60345 |
comparison
equal
deleted
inserted
replaced
42:498e4732bc1f | 43:fb5be14ea930 |
---|---|
1 """Classes for various buildings in the game.""" | |
2 | |
3 from pgu.vid import Sprite | |
4 | |
5 import imagecache | |
6 | |
7 class Building(Sprite): | |
8 """Base class for buildings""" | |
9 | |
10 def __init__(self, image, pos): | |
11 # Create the building somewhere far off screen | |
12 Sprite.__init__(self, image, (-1000, -1000)) | |
13 self.pos = pos | |
14 | |
15 def loop(self, tv, _sprite): | |
16 ppos = tv.tile_to_view(self.pos) | |
17 self.rect.x = ppos[0] | |
18 self.rect.y = ppos[1] | |
19 | |
20 def move(self, state): | |
21 """Given the game state, return a new position for the object""" | |
22 # Default is not to move | |
23 return self.pos | |
24 | |
25 class HenHouse(Building): | |
26 """A HenHouse.""" | |
27 | |
28 def __init__(self, pos): | |
29 image = imagecache.load_image('sprites/henhouse.png') | |
30 Building.__init__(self, image, pos) |