Merge branch 'master' of https://git.wmi.amu.edu.pl/s440556/SZI2019SmieciarzWmi
This commit is contained in:
commit
0ffc5fa187
@ -22,5 +22,5 @@ def set_home_amount():
|
|||||||
|
|
||||||
home_amount = 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
|
PLAY_HEIGHT = PLAY_WIDTH
|
||||||
|
3
game.py
3
game.py
@ -28,8 +28,9 @@ display.set_caption('Smieciarz WMI')
|
|||||||
##
|
##
|
||||||
# Generate level
|
# Generate level
|
||||||
utils.generate_grass(all_sprites)
|
utils.generate_grass(all_sprites)
|
||||||
utils.generate_houses(all_sprites, obstacles_coords)
|
|
||||||
utils.generate_landfills(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)
|
gc = utils.generate_garbage_collector(all_sprites, obstacles_coords)
|
||||||
##
|
##
|
||||||
|
|
||||||
|
28
utils.py
28
utils.py
@ -12,6 +12,12 @@ from sprites.garbage_collector import Garbage_collector
|
|||||||
def generate_rand_coordinates(max_x, max_y):
|
def generate_rand_coordinates(max_x, max_y):
|
||||||
return (random.randint(0, max_x), random.randint(0, (max_y)))
|
return (random.randint(0, max_x), random.randint(0, (max_y)))
|
||||||
|
|
||||||
|
def add_frame_as_obstacles(obstacles_coords):
|
||||||
|
for x in range(0, home_amount + 1):
|
||||||
|
obstacles_coords.append((x,-1))
|
||||||
|
obstacles_coords.append((-1,x))
|
||||||
|
obstacles_coords.append((PLAY_WIDTH//CELL_SIZE,x))
|
||||||
|
obstacles_coords.append((x,PLAY_HEIGHT//CELL_SIZE))
|
||||||
|
|
||||||
##GENERATE GRASS##################################################################
|
##GENERATE GRASS##################################################################
|
||||||
def generate_grass(all_sprites):
|
def generate_grass(all_sprites):
|
||||||
@ -34,7 +40,8 @@ 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):
|
if(((x, y) or (x+1,y)) not in obstacles_coords):
|
||||||
|
print(x,y)
|
||||||
houses.append(House(x, y, 10, 10, 10))
|
houses.append(House(x, y, 10, 10, 10))
|
||||||
obstacles_coords.append((x, y))
|
obstacles_coords.append((x, y))
|
||||||
home_counter = home_counter - 1
|
home_counter = home_counter - 1
|
||||||
@ -49,13 +56,20 @@ def generate_houses(all_sprites, obstacles_coords):
|
|||||||
def generate_landfills(all_sprites, obstacles_coords):
|
def generate_landfills(all_sprites, obstacles_coords):
|
||||||
landfills = []
|
landfills = []
|
||||||
landfill_counter = 3
|
landfill_counter = 3
|
||||||
while(landfill_counter != 0):
|
|
||||||
x, y = generate_rand_coordinates(
|
# while(landfill_counter != 0):
|
||||||
(PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
|
# x, y = generate_rand_coordinates(
|
||||||
if((x, y) not in obstacles_coords):
|
# (PLAY_WIDTH//CELL_SIZE)-1, (PLAY_HEIGHT//CELL_SIZE)-1)
|
||||||
landfills.append(Landfill(x, y, landfill_counter-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))
|
obstacles_coords.append((x,y))
|
||||||
landfill_counter = landfill_counter - 1
|
|
||||||
|
|
||||||
|
|
||||||
for item in landfills:
|
for item in landfills:
|
||||||
all_sprites.add(item)
|
all_sprites.add(item)
|
||||||
|
Loading…
Reference in New Issue
Block a user