Male_zoo_Projekt_SI/animal.py

49 lines
1.6 KiB
Python

import pygame
from abc import ABC, abstractmethod
class Animal:
def __init__(self, x, y,name, image, food_image, food, environment, adult=False,):
self.x = x - 1
self.y = y - 1
self.name = name
self.image = image
self.adult = adult
self.food = food
self.food_image = food_image
self._feed = 0
self.environment = environment #hot/cold/medium
def draw(self, screen, grid_size):
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
if self.adult:
# If adult, draw like AdultAnimal
new_width = grid_size * 2
new_height = grid_size * 2
scaled_image = pygame.transform.scale(self.image, (new_width, new_height))
screen.blit(scaled_image, (self.x * grid_size, self.y * grid_size))
else:
# If not adult, draw like normal Animal
screen.blit(self.image, (self.x * grid_size, self.y * grid_size))
def draw_exclamation(self, screen, grid_size, x, y):
exclamation_image = pygame.image.load('images/exclamation.png')
exclamation_image = pygame.transform.scale(exclamation_image, (grid_size,grid_size))
screen.blit(exclamation_image, (x*grid_size, y*grid_size - grid_size))
def draw_food(self, screen, grid_size, x, y):
food_image = pygame.image.load(self.food_image)
food_image = pygame.transform.scale(food_image, (grid_size,grid_size))
screen.blit(food_image, (x*grid_size, y*grid_size + grid_size))
@abstractmethod
def feed(self):
pass
@abstractmethod
def getting_hungry(self):
pass