Half repaired map-generating
This commit is contained in:
parent
dd6a57c701
commit
7d13d98757
@ -22,5 +22,5 @@ def set_home_amount():
|
||||
|
||||
home_amount = set_home_amount()
|
||||
|
||||
PLAY_WIDTH = home_amount*CELL_SIZE
|
||||
PLAY_WIDTH = (home_amount+2)*CELL_SIZE
|
||||
PLAY_HEIGHT = PLAY_WIDTH
|
||||
|
2
game.py
2
game.py
@ -27,8 +27,8 @@ display.set_caption('Smieciarz WMI')
|
||||
##
|
||||
# Generate level
|
||||
utils.generate_grass(all_sprites)
|
||||
utils.generate_houses(all_sprites, obstacles_coords)
|
||||
utils.generate_landfills(all_sprites, obstacles_coords)
|
||||
utils.generate_houses(all_sprites, obstacles_coords)
|
||||
utils.add_frame_as_obstacles(obstacles_coords)
|
||||
gc = utils.generate_garbage_collector(all_sprites, obstacles_coords)
|
||||
##
|
||||
|
21
utils.py
21
utils.py
@ -40,7 +40,7 @@ def generate_houses(all_sprites, obstacles_coords):
|
||||
while(home_counter != 0):
|
||||
x, y = generate_rand_coordinates(
|
||||
(PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
|
||||
if((x, y) not in obstacles_coords):
|
||||
if(((x, y) or (x,y-1)) not in obstacles_coords):
|
||||
houses.append(House(x, y, 10, 10, 10))
|
||||
obstacles_coords.append((x, y))
|
||||
home_counter = home_counter - 1
|
||||
@ -55,13 +55,20 @@ def generate_houses(all_sprites, obstacles_coords):
|
||||
def generate_landfills(all_sprites, obstacles_coords):
|
||||
landfills = []
|
||||
landfill_counter = 3
|
||||
while(landfill_counter != 0):
|
||||
x, y = generate_rand_coordinates(
|
||||
(PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
|
||||
if((x, y) not in obstacles_coords):
|
||||
landfills.append(Landfill(x, y, landfill_counter-1))
|
||||
|
||||
# while(landfill_counter != 0):
|
||||
# x, y = generate_rand_coordinates(
|
||||
# (PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
|
||||
# if((x, y) not in obstacles_coords):
|
||||
# landfills.append(Landfill(x, y, landfill_counter-1))
|
||||
# obstacles_coords.append((x, y))
|
||||
# landfill_counter = landfill_counter - 1
|
||||
y=0
|
||||
for x in range(landfill_counter):
|
||||
landfills.append(Landfill(x,y,x))
|
||||
obstacles_coords.append((x,y))
|
||||
landfill_counter = landfill_counter - 1
|
||||
|
||||
|
||||
|
||||
for item in landfills:
|
||||
all_sprites.add(item)
|
||||
|
Loading…
Reference in New Issue
Block a user