dodanie pozostałych zwierząt
BIN
__pycache__/bear.cpython-311.pyc
Normal file
BIN
__pycache__/giraffe.cpython-311.pyc
Normal file
BIN
__pycache__/parrot.cpython-311.pyc
Normal file
BIN
__pycache__/penguin.cpython-311.pyc
Normal file
@ -7,7 +7,7 @@ class Animal:
|
|||||||
self.y = y - 1
|
self.y = y - 1
|
||||||
self.image = image
|
self.image = image
|
||||||
self.adult = adult
|
self.adult = adult
|
||||||
self._feed = 0 #nowe zierze jest głodne
|
self._feed = 0 #nowe zwierze jest głodne
|
||||||
|
|
||||||
def draw(self, screen, grid_size):
|
def draw(self, screen, grid_size):
|
||||||
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
|
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
|
||||||
|
29
bear.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from animal import Animal
|
||||||
|
import pygame
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Bear(Animal):
|
||||||
|
def __init__(self, x, y, adult=False):
|
||||||
|
Bear_image = pygame.image.load('images/bear.png')
|
||||||
|
super().__init__(x, y, Bear_image, adult)
|
||||||
|
self.food_type = "fish"
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def feed(self):
|
||||||
|
self.getting_hungry()
|
||||||
|
if self._feed < 5:
|
||||||
|
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
|
@ -6,7 +6,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
class Elephant(Animal):
|
class Elephant(Animal):
|
||||||
def __init__(self, x, y, adult=False):
|
def __init__(self, x, y, adult=False):
|
||||||
Elephant_image = pygame.image.load('elephant.png')
|
Elephant_image = pygame.image.load('images/elephant.png')
|
||||||
super().__init__(x, y, Elephant_image, adult)
|
super().__init__(x, y, Elephant_image, adult)
|
||||||
self.food_type = "leaves"
|
self.food_type = "leaves"
|
||||||
self._starttime = datetime.now()
|
self._starttime = datetime.now()
|
||||||
|
29
giraffe.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from animal import Animal
|
||||||
|
import pygame
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Giraffe(Animal):
|
||||||
|
def __init__(self, x, y, adult=False):
|
||||||
|
Giraffe_image = pygame.image.load('images/giraffe.png')
|
||||||
|
super().__init__(x, y, Giraffe_image, adult)
|
||||||
|
self.food_type = "leaves"
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def feed(self):
|
||||||
|
self.getting_hungry()
|
||||||
|
if self._feed < 3:
|
||||||
|
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
|
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 248 KiB |
BIN
images/bear.png
Normal file
After Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 642 KiB After Width: | Height: | Size: 642 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
BIN
images/giraffe.png
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
images/parrot.png
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
images/penguin.png
Normal file
After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 209 KiB |
21
main.py
@ -1,11 +1,15 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import sys
|
import sys
|
||||||
from elephant import Elephant
|
from elephant import Elephant
|
||||||
|
from giraffe import Giraffe
|
||||||
|
from penguin import Penguin
|
||||||
|
from parrot import Parrot
|
||||||
|
from bear import Bear
|
||||||
from agent import Agent
|
from agent import Agent
|
||||||
|
|
||||||
BLACK = (0, 0, 0)
|
BLACK = (0, 0, 0)
|
||||||
|
|
||||||
GRID_SIZE = 75
|
GRID_SIZE = 50
|
||||||
GRID_WIDTH = 20
|
GRID_WIDTH = 20
|
||||||
GRID_HEIGHT = 10
|
GRID_HEIGHT = 10
|
||||||
|
|
||||||
@ -17,18 +21,19 @@ pygame.display.set_caption("Mini Zoo")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
background_image = pygame.image.load('tło.jpg')
|
background_image = pygame.image.load('images/tło.jpg')
|
||||||
background_image = pygame.transform.scale(background_image, WINDOW_SIZE)
|
background_image = pygame.transform.scale(background_image, WINDOW_SIZE)
|
||||||
|
|
||||||
exclamation_image = pygame.image.load('exclamation.png')
|
exclamation_image = pygame.image.load('images/exclamation.png')
|
||||||
exclamation_image = pygame.transform.scale(exclamation_image, (GRID_SIZE,GRID_SIZE))
|
exclamation_image = pygame.transform.scale(exclamation_image, (GRID_SIZE,GRID_SIZE))
|
||||||
|
|
||||||
an1 = Elephant(10, 2)
|
an1 = Parrot(10, 2)
|
||||||
an2 = Elephant(12, 2)
|
an2 = Penguin(12, 2)
|
||||||
an3 = Elephant(14, 7)
|
an3 = Bear(14, 10)
|
||||||
|
old_an2 = Giraffe(18,4, adult=True)
|
||||||
old_an1 = Elephant(3, 6, adult=True)
|
old_an1 = Elephant(3, 6, adult=True)
|
||||||
|
|
||||||
Animals = [an1, an2, an3,old_an1]
|
Animals = [an1, an2, an3, old_an1, old_an2]
|
||||||
|
|
||||||
def draw_grid():
|
def draw_grid():
|
||||||
for y in range(0, GRID_HEIGHT * GRID_SIZE, GRID_SIZE):
|
for y in range(0, GRID_HEIGHT * GRID_SIZE, GRID_SIZE):
|
||||||
@ -48,7 +53,7 @@ def draw_Animals():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
agent = Agent(0, 0, 'avatar.png', GRID_SIZE)
|
agent = Agent(0, 0, 'images/avatar.png', GRID_SIZE)
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
29
parrot.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from animal import Animal
|
||||||
|
import pygame
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Parrot(Animal):
|
||||||
|
def __init__(self, x, y, adult=False):
|
||||||
|
Parrot_image = pygame.image.load('images/parrot.png')
|
||||||
|
super().__init__(x, y, Parrot_image, adult)
|
||||||
|
self.food_type = "grain"
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def feed(self):
|
||||||
|
self.getting_hungry()
|
||||||
|
if self._feed < 3:
|
||||||
|
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
|
29
penguin.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from animal import Animal
|
||||||
|
import pygame
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Penguin(Animal):
|
||||||
|
def __init__(self, x, y, adult=False):
|
||||||
|
Penguin_image = pygame.image.load('images/penguin.png')
|
||||||
|
super().__init__(x, y, Penguin_image, adult)
|
||||||
|
self.food_type = "fish"
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def feed(self):
|
||||||
|
self.getting_hungry()
|
||||||
|
if self._feed < 2:
|
||||||
|
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
|