comparison gamelib/animal.py @ 98:725b292ca07b

Added sounds killing foxes and chickens, and nightfall Renamed sounds for clarity
author David Fraser <davidf@sjsoft.com>
date Wed, 02 Sep 2009 12:14:24 +0000
parents bea1b9364583
children d17375586866
comparison
equal deleted inserted replaced
97:529a4d41c67a 98:725b292ca07b
6 from pgu.algo import getline 6 from pgu.algo import getline
7 7
8 import imagecache 8 import imagecache
9 import tiles 9 import tiles
10 from misc import Position 10 from misc import Position
11 import sound
11 12
12 class Animal(Sprite): 13 class Animal(Sprite):
13 """Base class for animals""" 14 """Base class for animals"""
14 15
15 def __init__(self, image_left, image_right, tile_pos): 16 def __init__(self, image_left, image_right, tile_pos):
75 weapon = self.weapons()[0] 76 weapon = self.weapons()[0]
76 fox = self._find_killable_fox(weapon, gameboard) 77 fox = self._find_killable_fox(weapon, gameboard)
77 if not fox: 78 if not fox:
78 return 79 return
79 if weapon.hit(gameboard, self, fox): 80 if weapon.hit(gameboard, self, fox):
81 sound.play_sound("kill-fox.ogg")
80 gameboard.kill_fox(fox) 82 gameboard.kill_fox(fox)
81 83
82 class Egg(Animal): 84 class Egg(Animal):
83 """An egg""" 85 """An egg"""
84 86
198 return self.pos 200 return self.pos
199 return self._find_best_path_step(closest.pos, gameboard) 201 return self._find_best_path_step(closest.pos, gameboard)
200 202
201 def _catch_chicken(self, chicken, gameboard): 203 def _catch_chicken(self, chicken, gameboard):
202 """Catch a chicken""" 204 """Catch a chicken"""
205 sound.play_sound("kill-chicken.ogg")
203 gameboard.remove_chicken(chicken) 206 gameboard.remove_chicken(chicken)
204 self.hunting = False 207 self.hunting = False
205 208
206 def _update_pos(self, gameboard, new_pos): 209 def _update_pos(self, gameboard, new_pos):
207 """Update the position, making sure we don't step on other foxes""" 210 """Update the position, making sure we don't step on other foxes"""