Mercurial > rinkhals
comparison gamelib/animal.py @ 108:437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 18:42:00 +0000 |
parents | d17375586866 |
children | 48019afde338 |
comparison
equal
deleted
inserted
replaced
107:672cc5598e77 | 108:437cbd856a03 |
---|---|
18 Sprite.__init__(self, image_left, (-1000, -1000)) | 18 Sprite.__init__(self, image_left, (-1000, -1000)) |
19 self.image_left = image_left | 19 self.image_left = image_left |
20 self.image_right = image_right | 20 self.image_right = image_right |
21 self.pos = Position(tile_pos[0], tile_pos[1]) | 21 self.pos = Position(tile_pos[0], tile_pos[1]) |
22 self.equipment = [] | 22 self.equipment = [] |
23 self.abode = None | |
23 | 24 |
24 def loop(self, tv, _sprite): | 25 def loop(self, tv, _sprite): |
25 ppos = tv.tile_to_view(self.pos.to_tuple()) | 26 ppos = tv.tile_to_view(self.pos.to_tuple()) |
26 self.rect.x = ppos[0] | 27 self.rect.x = ppos[0] |
27 self.rect.y = ppos[1] | 28 self.rect.y = ppos[1] |
28 | 29 |
29 def move(self, state): | 30 def move(self, state): |
30 """Given the game state, return a new position for the object""" | 31 """Given the game state, return a new position for the object""" |
31 # Default is not to move | 32 # Default is not to move |
32 pass | 33 pass |
34 | |
35 def set_pos(self, tile_pos): | |
36 """Move an animal to the given tile_pos.""" | |
37 new_pos = Position(*tile_pos) | |
38 self._fix_face(new_pos) | |
39 self.pos = new_pos | |
33 | 40 |
34 def _fix_face(self, final_pos): | 41 def _fix_face(self, final_pos): |
35 """Set the face correctly""" | 42 """Set the face correctly""" |
36 if final_pos.left_of(self.pos): | 43 if final_pos.left_of(self.pos): |
37 self.setimage(self.image_left) | 44 self.setimage(self.image_left) |