added additional condition for generating houses

This commit is contained in:
Anna Nowak 2019-03-25 17:43:08 +01:00
parent af1f91c4f0
commit d6df436085

View File

@ -33,7 +33,7 @@ def generate_houses(all_sprites, obstacles_coords):
while(home_counter != 0): while(home_counter != 0):
x, y = generate_rand_coordinates( x, y = generate_rand_coordinates(
(PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1) (PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
if(((x, y)) not in obstacles_coords["homes"] and ((x, y)) not in obstacles_coords["landfills"]): if(((x, y)) not in obstacles_coords["homes"] and ((x, y)) not in obstacles_coords["landfills"] and ((x, y-1)) not in obstacles_coords["landfills"]):
houses.append(House(x, y, 10, 10, 10)) houses.append(House(x, y, 10, 10, 10))
obstacles_coords["homes"].append((x, y)) obstacles_coords["homes"].append((x, y))
home_counter = home_counter - 1 home_counter = home_counter - 1