comparison gamelib/animal.py @ 28:ac3a74352b74

Change animal.py to four space indents.
author Simon Cross <hodgestar@gmail.com>
date Sun, 30 Aug 2009 18:23:40 +0000
parents 6d6ab0c1479d
children 2e88c680672c
comparison
equal deleted inserted replaced
27:049d5a19073b 28:ac3a74352b74
4 from pgu.vid import Sprite 4 from pgu.vid import Sprite
5 5
6 import data 6 import data
7 7
8 class Animal(Sprite): 8 class Animal(Sprite):
9 """Base class for animals""" 9 """Base class for animals"""
10 10
11 def __init__(self, image, pos): 11 def __init__(self, image, pos):
12 Sprite.__init__(self, image, pos) 12 Sprite.__init__(self, image, pos)
13 self.pos = pos 13 self.pos = pos
14 14
15 def loop(self, tv, _sprite): 15 def loop(self, tv, _sprite):
16 ppos = tv.tile_to_view(self.pos) 16 ppos = tv.tile_to_view(self.pos)
17 self.rect.x = ppos[0] 17 self.rect.x = ppos[0]
18 self.rect.y = ppos[1] 18 self.rect.y = ppos[1]
19 19
20 def move(self, state): 20 def move(self, state):
21 """Given the game state, return a new position for the object""" 21 """Given the game state, return a new position for the object"""
22 # Default is not to move 22 # Default is not to move
23 return self.pos 23 return self.pos
24 24
25 class Chicken(Animal): 25 class Chicken(Animal):
26 """A chicken""" 26 """A chicken"""
27 27
28 def __init__(self, pos): 28 def __init__(self, pos):
29 image = pygame.image.load(data.filepath('sprites/chkn.png')) 29 image = pygame.image.load(data.filepath('sprites/chkn.png'))
30 Animal.__init__(self, image, pos) 30 Animal.__init__(self, image, pos)
31 31
32 def move(self, gameboard): 32 def move(self, gameboard):
33 """A free chicken will move away from other free chickens""" 33 """A free chicken will move away from other free chickens"""
34 return self.pos 34 return self.pos
35 35
36 class Egg(Animal): 36 class Egg(Animal):
37 """An egg""" 37 """An egg"""
38 38
39 # Eggs don't move 39 # Eggs don't move
40 40
41 class Fox(Animal): 41 class Fox(Animal):
42 """A fox""" 42 """A fox"""
43 43
44 def __init__(self, pos): 44 def __init__(self, pos):
45 image = pygame.image.load(data.filepath('sprites/fox.png')) 45 image = pygame.image.load(data.filepath('sprites/fox.png'))
46 Animal.__init__(self, image, pos) 46 Animal.__init__(self, image, pos)
47 47
48 def move(self, gameboard): 48 def move(self, gameboard):
49 """Foxes will aim to move towards the closest henhouse or free 49 """Foxes will aim to move towards the closest henhouse or free
50 chicken""" 50 chicken"""
51 return self.pos 51 return self.pos
52