43
|
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)
|