Przeszukiwanie-stanów-A_star #2

Merged
s481832 merged 12 commits from Przeszukiwanie-stanów-A_star into master 2024-05-08 12:00:16 +02:00
6 changed files with 10 additions and 11 deletions
Showing only changes of commit ff27920f3d - Show all commits

View File

@ -6,22 +6,21 @@ class Agent:
self.istate = istate
self.x, self.y, self.direction = istate
self.grid_size = grid_size
self.image_original = pygame.image.load(image_path)
self.image_original = pygame.transform.scale(self.image_original, (grid_size, grid_size))
self.image = self.image_original
self.image= pygame.image.load(image_path)
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
def draw(self, screen):
def draw(self, screen, grid_size):
# Obróć obrazek zgodnie z kierunkiem
if self.direction == 'E':
self.image = pygame.transform.rotate(self.image_original, -90)
self.image= pygame.image.load('images/agent4.png')
elif self.direction == 'S':
self.image = pygame.transform.rotate(self.image_original, 180)
self.image= pygame.image.load('images/agent1.png')
elif self.direction == 'W':
self.image = pygame.transform.rotate(self.image_original, 90)
self.image= pygame.image.load('images/agent3.png')
else: # direction == 'N'
self.image = self.image_original
self.image= pygame.image.load('images/agent2.png')
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
screen.blit(self.image, (self.x * self.grid_size, self.y * self.grid_size))
def handle_event(self, event, max_x, max_y, animals, obstacles):

BIN
images/agent1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
images/agent2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
images/agent3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
images/agent4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -154,7 +154,7 @@ def generate_obstacles():
def main():
initial_state = (1,1,'W')
agent = Agent(initial_state, 'images/agent.png', GRID_SIZE)
agent = Agent(initial_state, 'images/agent1.png', GRID_SIZE)
obstacles = generate_obstacles()
@ -185,7 +185,7 @@ def main():
spawned = True
draw_Animals()
opengates()
agent.draw(screen)
agent.draw(screen, GRID_SIZE)
pygame.display.flip()
clock.tick(10)