source: gamelib/buildings.py @ 43:fb5be14ea930

Last change on this file since 43:fb5be14ea930 was 43:fb5be14ea930, checked in by Simon Cross <hodgestar@…>, 11 years ago

Start of building sprites.

File size: 802 bytes
Line 
1"""Classes for various buildings in the game."""
2
3from pgu.vid import Sprite
4
5import imagecache
6
7class 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
25class 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)
Note: See TracBrowser for help on using the repository browser.