def process(self, time_passed): r = randint(1, 10000) if r < self.hunger: self.meowSound.play() if self.hunger > self.THRESHOLD_HUNGRY: self.hungerColour = (255, 0, 0) elif self.hunger > self.THRESHOLD_VERY_HUNGRY: self.hungerColour = (255, 255, 0) else: self.hungerColour = (0, 255, 0) AnimatedGameEntity.process(self, time_passed)
def __init__(self, startCoordinates, world, name='cat'): AnimatedGameEntity.__init__(self, startCoordinates, name=name) self.hunger = 35 self.brain.add_state(CatRoaming(self)) self.brain.add_state(CatRunningToPot(self)) self.brain.add_state(CatEating(self)) self.destination = self.location self.world = world self.pot = None self.hungerColor = (0, 255, 0) self.perceptionRange = 250 self.brain.set_state("roaming")
def render(self, surface, offset): AnimatedGameEntity.render(self, surface, offset) surface.fill(self.hungerColour, (self.location.x - offset[0], self.location.y - offset[1] + self.image.get_height() + 5, self.hunger, 4))