comparison gamelib/animal.py @ 44:7e884084e7b1

Move animal sprites to imagecache.
author Simon Cross <hodgestar@gmail.com>
date Mon, 31 Aug 2009 16:49:59 +0000
parents 03121c89d5fd
children be2496df2368
comparison
equal deleted inserted replaced
43:fb5be14ea930 44:7e884084e7b1
1 """Class for the various animals in the game""" 1 """Class for the various animals in the game"""
2 2
3 import pygame
4 import random
5 from pgu.vid import Sprite 3 from pgu.vid import Sprite
6 4
7 import data 5 import imagecache
8 6
9 class Animal(Sprite): 7 class Animal(Sprite):
10 """Base class for animals""" 8 """Base class for animals"""
11 9
12 def __init__(self, image, pos): 10 def __init__(self, image, pos):
26 24
27 class Chicken(Animal): 25 class Chicken(Animal):
28 """A chicken""" 26 """A chicken"""
29 27
30 def __init__(self, pos): 28 def __init__(self, pos):
31 image = pygame.image.load(data.filepath('sprites/chkn.png')) 29 image = imagecache.load_image('sprites/chkn.png')
32 Animal.__init__(self, image, pos) 30 Animal.__init__(self, image, pos)
33 31
34 def move(self, gameboard): 32 def move(self, gameboard):
35 """A free chicken will move away from other free chickens""" 33 """A free chicken will move away from other free chickens"""
36 return self.pos 34 return self.pos
42 40
43 class Fox(Animal): 41 class Fox(Animal):
44 """A fox""" 42 """A fox"""
45 43
46 def __init__(self, pos): 44 def __init__(self, pos):
47 image = pygame.image.load(data.filepath('sprites/fox.png')) 45 image = imagecache.load_image('sprites/fox.png')
48 self.full = False 46 self.full = False
49 Animal.__init__(self, image, pos) 47 Animal.__init__(self, image, pos)
50 48
51 def move(self, gameboard): 49 def move(self, gameboard):
52 """Foxes will aim to move towards the closest henhouse or free 50 """Foxes will aim to move towards the closest henhouse or free