dorosłe osobniki
This commit is contained in:
parent
c46e523488
commit
82b2060409
16
adult_animal.py
Normal file
16
adult_animal.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
from animal import Animal
|
||||||
|
|
||||||
|
class AdultAnimal(Animal):
|
||||||
|
def __init__(self,x,y,image, width=2,height=2):
|
||||||
|
super().__init__(x,y,image)
|
||||||
|
self.width=width
|
||||||
|
self.height=height
|
||||||
|
|
||||||
|
def draw(self, screen, grid_size):
|
||||||
|
new_width = grid_size * self.width
|
||||||
|
new_height = grid_size * self.height
|
||||||
|
scaled_image = pygame.transform.scale(self.image, (new_width, new_height))
|
||||||
|
|
||||||
|
screen.blit(scaled_image, (self.x * grid_size, self.y * grid_size))
|
11
main.py
11
main.py
@ -1,6 +1,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import sys
|
import sys
|
||||||
from animal import Animal
|
from animal import Animal
|
||||||
|
from adult_animal import AdultAnimal
|
||||||
|
|
||||||
BLACK = (0, 0, 0)
|
BLACK = (0, 0, 0)
|
||||||
|
|
||||||
@ -28,11 +29,16 @@ an1=Animal(10,1,animal_image)
|
|||||||
an2=Animal(12,1,animal_image)
|
an2=Animal(12,1,animal_image)
|
||||||
an3=Animal(14,7,animal_image)
|
an3=Animal(14,7,animal_image)
|
||||||
|
|
||||||
|
old_an1=AdultAnimal(3,6, animal_image,width=2,height=2)
|
||||||
|
|
||||||
animals=[]
|
animals=[]
|
||||||
animals.append(an1)
|
animals.append(an1)
|
||||||
animals.append(an2)
|
animals.append(an2)
|
||||||
animals.append(an3)
|
animals.append(an3)
|
||||||
|
|
||||||
|
old_animals=[]
|
||||||
|
old_animals.append(old_an1)
|
||||||
|
|
||||||
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):
|
||||||
for x in range(0, GRID_WIDTH * GRID_SIZE, GRID_SIZE):
|
for x in range(0, GRID_WIDTH * GRID_SIZE, GRID_SIZE):
|
||||||
@ -47,6 +53,10 @@ def draw_animals():
|
|||||||
for animal in animals:
|
for animal in animals:
|
||||||
animal.draw(screen,GRID_SIZE)
|
animal.draw(screen,GRID_SIZE)
|
||||||
|
|
||||||
|
def draw_old_animals():
|
||||||
|
for animal in old_animals:
|
||||||
|
animal.draw(screen,GRID_SIZE)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global agent_pos
|
global agent_pos
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
@ -70,6 +80,7 @@ def main():
|
|||||||
screen.blit(background_image,(0,0))
|
screen.blit(background_image,(0,0))
|
||||||
draw_grid()
|
draw_grid()
|
||||||
draw_animals()
|
draw_animals()
|
||||||
|
draw_old_animals()
|
||||||
draw_agent(agent_pos)
|
draw_agent(agent_pos)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
clock.tick(10)
|
clock.tick(10)
|
||||||
|
Loading…
Reference in New Issue
Block a user