zdefiniowanie trybu zycia zwierzecia, dodanie mozliwosci zachorowania przy spawnie
This commit is contained in:
parent
3baf0209a0
commit
693a8617f7
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,8 +1,10 @@
|
||||
import random
|
||||
|
||||
import pygame
|
||||
from abc import abstractmethod
|
||||
|
||||
class Animal:
|
||||
def __init__(self, x, y,name, image, food_image, food, environment, adult=False,):
|
||||
def __init__(self, x, y,name, image, food_image, food, environment, activity, ill=False, adult=False,):
|
||||
self.x = x - 1
|
||||
self.y = y - 1
|
||||
self.name = name
|
||||
@ -11,7 +13,9 @@ class Animal:
|
||||
self.food = food
|
||||
self.food_image = food_image
|
||||
self._feed = 0
|
||||
self.environment = environment #hot/cold/medium
|
||||
self.environment = environment # hot/cold/medium
|
||||
self.activity = activity # diurnal/nocturnal
|
||||
self.ill = ill
|
||||
|
||||
def draw(self, screen, grid_size):
|
||||
if self.adult:
|
||||
@ -40,6 +44,24 @@ class Animal:
|
||||
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)))
|
||||
|
||||
def is_ill(self):
|
||||
chance = random.randint(1, 100)
|
||||
if chance >= 90:
|
||||
return True
|
||||
|
||||
def draw_illness(self, screen, grid_size, x, y):
|
||||
scale = 0.45
|
||||
illness_image = pygame.image.load('images/ill.png')
|
||||
y = y
|
||||
|
||||
if self.adult:
|
||||
x = x + 1
|
||||
y = y
|
||||
scale = 0.7
|
||||
|
||||
x_blit = x * grid_size + (grid_size - int(grid_size * scale))
|
||||
illness_image = pygame.transform.scale(illness_image, (int(grid_size * scale), int(grid_size * scale)))
|
||||
screen.blit(illness_image, (x_blit, y * grid_size))
|
||||
|
||||
@abstractmethod
|
||||
def getting_hungry(self):
|
||||
|
@ -51,3 +51,5 @@ def draw_Animals(Animals, const):
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/half_bowl.png')
|
||||
if Animal.getting_hungry() < 2:
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/full_bowl.png')
|
||||
if Animal.ill:
|
||||
Animal.draw_illness(const.screen, const.GRID_SIZE, Animal.x, Animal.y)
|
@ -7,9 +7,11 @@ class Bear(Animal):
|
||||
Bear_image = pygame.image.load('images/bear.png')
|
||||
name = 'bear'
|
||||
environment = "cold"
|
||||
activity = 'nocturnal'
|
||||
ill = self.is_ill()
|
||||
bear_food = 'meat'
|
||||
food_image = 'images/meat.png'
|
||||
super().__init__(x, y,name, Bear_image, food_image,bear_food,environment, adult)
|
||||
super().__init__(x, y,name, Bear_image, food_image,bear_food,environment, activity, ill, adult)
|
||||
self._starttime = datetime.now()
|
||||
|
||||
|
||||
|
@ -9,6 +9,8 @@ class Elephant(Animal):
|
||||
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'
|
||||
@ -16,7 +18,7 @@ class Elephant(Animal):
|
||||
elephant_food = 'milk'
|
||||
food_image = 'images/milk.png'
|
||||
|
||||
super().__init__(x, y,name, Elephant_image, food_image,elephant_food, environment, adult)
|
||||
super().__init__(x, y,name, Elephant_image, food_image,elephant_food, environment, activity, ill, adult)
|
||||
self._starttime = datetime.now()
|
||||
|
||||
|
||||
|
@ -9,9 +9,11 @@ class Giraffe(Animal):
|
||||
Giraffe_image = pygame.image.load('images/giraffe.png')
|
||||
name = 'giraffe'
|
||||
environment = "hot"
|
||||
activity = 'diurnal'
|
||||
ill = self.is_ill()
|
||||
food_image = 'images/leaves.png'
|
||||
giraffe_food = 'leaves'
|
||||
super().__init__(x, y,name, Giraffe_image, food_image,giraffe_food, environment, adult)
|
||||
super().__init__(x, y, name, Giraffe_image, food_image,giraffe_food, environment, activity, ill, adult)
|
||||
self._starttime = datetime.now()
|
||||
|
||||
|
||||
|
@ -9,9 +9,11 @@ class Parrot(Animal):
|
||||
Parrot_image = pygame.image.load('images/parrot.png')
|
||||
name = 'parrot'
|
||||
environment = "medium"
|
||||
activity = 'diurnal'
|
||||
ill = self.is_ill()
|
||||
food_image = 'images/grains.png'
|
||||
parrot_food = 'grains'
|
||||
super().__init__(x, y,name, Parrot_image, food_image,parrot_food, environment, adult)
|
||||
super().__init__(x, y, name, Parrot_image, food_image, parrot_food, environment, activity, ill, adult)
|
||||
self._starttime = datetime.now()
|
||||
|
||||
|
||||
|
@ -9,9 +9,11 @@ class Penguin(Animal):
|
||||
Penguin_image = pygame.image.load('images/penguin.png')
|
||||
name = 'penguin'
|
||||
environment = "cold"
|
||||
activity = 'diurnal'
|
||||
ill = self.is_ill()
|
||||
food_image = 'images/fish.png'
|
||||
penguin_food = 'fish'
|
||||
super().__init__(x, y,name, Penguin_image, food_image,penguin_food,environment, adult)
|
||||
super().__init__(x, y, name, Penguin_image, food_image, penguin_food, environment, activity, ill, adult)
|
||||
self._starttime = datetime.now()
|
||||
|
||||
|
||||
|
BIN
images/ill.png
Normal file
BIN
images/ill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in New Issue
Block a user