This commit is contained in:
Natalia Szymczak 2024-03-22 17:16:34 +01:00
parent df8dd868e7
commit bbc9deb5f9

20
main.py
View File

@ -26,10 +26,9 @@ exclamation_image = pygame.transform.scale(exclamation_image, (GRID_SIZE,GRID_SI
an1 = Elephant(10, 2)
an2 = Elephant(12, 2)
an3 = Elephant(14, 7)
old_an1 = Elephant(3, 6, adult=True)
Elephants = [an1, an2, an3,old_an1]
Animals = [an1, an2, an3,old_an1]
def draw_grid():
for y in range(0, GRID_HEIGHT * GRID_SIZE, GRID_SIZE):
@ -40,11 +39,11 @@ def draw_grid():
def draw_exclamation(x, y):
screen.blit(exclamation_image, (x*GRID_SIZE, y*GRID_SIZE - GRID_SIZE))
def draw_Elephants():
for Elephant in Elephants:
Elephant.draw(screen, GRID_SIZE)
if Elephant.feed() == 'True':
draw_exclamation(Elephant.x, Elephant.y)
def draw_Animals():
for Animal in Animals:
Animal.draw(screen, GRID_SIZE)
if Animal.feed() == 'True':
draw_exclamation(Animal.x, Animal.y)
@ -57,14 +56,13 @@ def main():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
agent.handle_event(event,GRID_HEIGHT,GRID_WIDTH,Elephants)
agent.handle_event(event,GRID_HEIGHT,GRID_WIDTH,Animals)
for Elephant in Elephants:
Elephant.getting_hungry()
screen.blit(background_image,(0,0))
draw_grid()
draw_Elephants()
draw_Animals()