From 62afec7910a6c21b6000ed84d4fa5ea8b8889d91 Mon Sep 17 00:00:00 2001 From: Neerka Date: Mon, 11 Mar 2024 14:55:22 +0100 Subject: [PATCH] positions_adjustment --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 510d1d8..50d21b9 100644 --- a/main.py +++ b/main.py @@ -51,7 +51,7 @@ for i in range(5): trashcans.append(trashcan) houses = [] -house_positions = [(100, 200), (400, 400), (150, 600), (800, 800), (1000, 200), (1200, 700), (700, 100), (500, 800)] +house_positions = [(450, 100), (250, 250), (200, 700), (850, 800), (1000, 200), (1050, 700), (800, 100), (400, 850)] for i in range(8): house_image = pygame.image.load(f'house_{i}.jpg') @@ -65,8 +65,9 @@ for i in range(len(houses)): else: neigh = chooseNeighbours(3, i) for num in neigh: - houses[i].addNeighbour(houses[num]) - houses[num].addNeighbour(houses[i]) + if len(houses[i].getNeighbours()) < 3 and len(houses[num].getNeighbours()) < 3: + houses[i].addNeighbour(houses[num]) + houses[num].addNeighbour(houses[i]) if i == 7 or i == 1: houses[i].addNeighbour(junkyard) junkyard.addNeighbour(houses[i]) @@ -89,6 +90,7 @@ while running: for neighbour in house.getNeighbours(): if neighbour.getId() < house.getId(): pygame.draw.line(screen, colors["black"], house.getPosition(), neighbour.getPosition(), 3) + for house in houses: screen.blit(house.getImage(), house.getPosition()) pygame.draw.circle(screen, colors["red"], junkyard.getPosition(), 10)