2024-03-22 16:59:39 +01:00
|
|
|
from animal import Animal
|
|
|
|
import pygame
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Elephant(Animal):
|
|
|
|
def __init__(self, x, y, adult=False):
|
2024-03-22 20:11:58 +01:00
|
|
|
Elephant_image = pygame.image.load('images/elephant.png')
|
2024-03-24 17:33:58 +01:00
|
|
|
name = 'elephant'
|
|
|
|
environment = "hot"
|
2024-03-23 13:55:16 +01:00
|
|
|
if adult:
|
|
|
|
elephant_food = 'leavs'
|
|
|
|
food_image = 'images/leaves.png'
|
|
|
|
else:
|
|
|
|
elephant_food = 'milk'
|
|
|
|
food_image = 'images/milk.png'
|
|
|
|
|
2024-03-24 17:33:58 +01:00
|
|
|
super().__init__(x, y,name, Elephant_image, food_image,elephant_food, environment, adult)
|
2024-03-22 16:59:39 +01:00
|
|
|
self._starttime = datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def feed(self):
|
|
|
|
self.getting_hungry()
|
2024-03-23 13:55:16 +01:00
|
|
|
if self._feed < 0.3:
|
2024-03-22 16:59:39 +01:00
|
|
|
return 'False'
|
|
|
|
else:
|
|
|
|
return 'True'
|
|
|
|
|
|
|
|
|
|
|
|
def getting_hungry(self):
|
|
|
|
checktime = datetime.now()
|
|
|
|
delta = checktime - self._starttime
|
|
|
|
minutes_passed = delta.total_seconds() / 60
|
|
|
|
self._feed += minutes_passed
|
|
|
|
self._starttime = checktime
|