Mercurial > rinkhals
changeset 43:fb5be14ea930
Start of building sprites.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Mon, 31 Aug 2009 16:49:12 +0000 |
parents | 498e4732bc1f |
children | 7e884084e7b1 |
files | gamelib/buildings.py |
diffstat | 1 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/buildings.py Mon Aug 31 16:49:12 2009 +0000 @@ -0,0 +1,30 @@ +"""Classes for various buildings in the game.""" + +from pgu.vid import Sprite + +import imagecache + +class Building(Sprite): + """Base class for buildings""" + + def __init__(self, image, pos): + # Create the building somewhere far off screen + Sprite.__init__(self, image, (-1000, -1000)) + self.pos = pos + + def loop(self, tv, _sprite): + ppos = tv.tile_to_view(self.pos) + self.rect.x = ppos[0] + self.rect.y = ppos[1] + + def move(self, state): + """Given the game state, return a new position for the object""" + # Default is not to move + return self.pos + +class HenHouse(Building): + """A HenHouse.""" + + def __init__(self, pos): + image = imagecache.load_image('sprites/henhouse.png') + Building.__init__(self, image, pos)