31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from animal import Animal
|
|
import pygame
|
|
from datetime import datetime
|
|
|
|
class Elephant(Animal):
|
|
def __init__(self, x, y, adult=False):
|
|
Elephant_image = pygame.image.load('images/elephant.png')
|
|
name = 'elephant'
|
|
environment = "hot"
|
|
activity = 'diurnal'
|
|
ill = self.is_ill()
|
|
if adult:
|
|
elephant_food = 'leavs'
|
|
food_image = 'images/leaves.png'
|
|
else:
|
|
elephant_food = 'milk'
|
|
food_image = 'images/milk.png'
|
|
|
|
super().__init__(x, y,name, Elephant_image, food_image,elephant_food, environment, activity, ill, adult)
|
|
self._starttime = datetime.now()
|
|
|
|
def getting_hungry(self, const):
|
|
checktime = datetime.now()
|
|
delta = checktime - self._starttime
|
|
minutes_passed = delta.total_seconds() / 50*5
|
|
self._starttime = checktime
|
|
|
|
if not const.IS_NIGHT and self._feed < 10:
|
|
self._feed += minutes_passed
|
|
self._feed = min(self._feed, 10)
|
|
return self._feed |