diff --git a/animal.py b/animal.py index 9e04896..32dbac8 100644 --- a/animal.py +++ b/animal.py @@ -1,7 +1,6 @@ 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 @@ -15,29 +14,31 @@ class Animal: self.environment = environment #hot/cold/medium def draw(self, screen, grid_size): - self.image = pygame.transform.scale(self.image, (grid_size, grid_size)) if self.adult: - # If adult, draw like AdultAnimal + # 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: - # If not adult, draw like normal Animal - screen.blit(self.image, (self.x * grid_size, self.y * grid_size)) + # 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, (grid_size,grid_size)) - screen.blit(exclamation_image, (x*grid_size, y*grid_size - grid_size)) + 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) - food_image = pygame.transform.scale(food_image, (grid_size,grid_size)) - screen.blit(food_image, (x*grid_size, y*grid_size + grid_size)) - - + 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): @@ -45,4 +46,4 @@ class Animal: @abstractmethod def getting_hungry(self): - pass + pass \ No newline at end of file diff --git a/images/avatar.png b/images/avatar.png deleted file mode 100644 index 19a2f6e..0000000 Binary files a/images/avatar.png and /dev/null differ diff --git a/images/avatar_old.png b/images/avatar_old.png deleted file mode 100644 index 4d290c1..0000000 Binary files a/images/avatar_old.png and /dev/null differ diff --git a/images/bear.png b/images/bear.png index e02a84f..3c5267b 100644 Binary files a/images/bear.png and b/images/bear.png differ diff --git a/images/exclamation.png b/images/exclamation.png index 4e7d6c7..2dd1b27 100644 Binary files a/images/exclamation.png and b/images/exclamation.png differ diff --git a/images/fish.png b/images/fish.png index 8a5f710..e396358 100644 Binary files a/images/fish.png and b/images/fish.png differ diff --git a/images/giraffe.png b/images/giraffe.png index 8035ad6..8247a89 100644 Binary files a/images/giraffe.png and b/images/giraffe.png differ diff --git a/images/meat.png b/images/meat.png index 34a3d23..fe2b9c6 100644 Binary files a/images/meat.png and b/images/meat.png differ diff --git a/images/milk.png b/images/milk.png index b51a627..326de64 100644 Binary files a/images/milk.png and b/images/milk.png differ diff --git a/images/parrot.png b/images/parrot.png index b38bf98..df1a787 100644 Binary files a/images/parrot.png and b/images/parrot.png differ diff --git a/images/penguin.png b/images/penguin.png index 6e80909..f82c874 100644 Binary files a/images/penguin.png and b/images/penguin.png differ diff --git a/main.py b/main.py index 9dcb48a..68fe5d4 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ from state_space_search import graphsearch BLACK = (0, 0, 0) -GRID_SIZE = 50 +GRID_SIZE = 64 GRID_WIDTH = 30 GRID_HEIGHT = 15 @@ -177,9 +177,10 @@ def main(): spawn_all_animals() # region Test szukania ścieżki + for animal in Animals: + animal._feed = 2 # Ustawienie aby zwierzę było głodne animal = random.choice(Animals) - actions = graphsearch(agent.istate, (animal.x, animal.y), GRID_WIDTH, GRID_HEIGHT, obstacles) - animal._feed = 2 # Ustawienie aby zwierzę było głodne + # actions = graphsearch(agent.istate, (animal.x, animal.y), GRID_WIDTH, GRID_HEIGHT, obstacles) # endregion spawned = True