Male_zoo_Projekt_SI/animal.py

49 lines
1.9 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):
if self.adult:
# Jeśli zwierzę jest dorosłe, skaluj obrazek na większy rozmiar
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:
# Jeśli zwierzę nie jest dorosłe, skaluj obrazek na rozmiar jednej kratki
scaled_image = pygame.transform.scale(self.image, (grid_size, grid_size))
screen.blit(scaled_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, (int(grid_size * 0.45), int(grid_size * 0.45)))
screen.blit(exclamation_image, (x * grid_size, y * grid_size))
def draw_food(self, screen, grid_size, x, y):
scale = 0.45
food_image = pygame.image.load(self.food_image)
if(self.adult):
y = y + 1
scale = 0.7
food_image = pygame.transform.scale(food_image, (int(grid_size * scale), int(grid_size * scale)))
screen.blit(food_image, (x * grid_size, (y + 1) * grid_size - int(grid_size * scale)))
@abstractmethod
def feed(self):
pass
@abstractmethod
def getting_hungry(self):
pass