added houses

This commit is contained in:
s481872 2024-03-10 18:04:48 +01:00
parent 934fe288b7
commit 0b767bba75
9 changed files with 22 additions and 6 deletions

BIN
house_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
house_1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
house_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

BIN
house_3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
house_4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
house_5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

BIN
house_6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

BIN
house_7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

28
main.py
View File

@ -15,7 +15,8 @@ trash_can_images = {
} }
new_garbage_truck_size = (120, 120) new_garbage_truck_size = (120, 120)
new_trash_can_size = (120, 120) new_trash_can_size = (90, 90)
new_house_size = (140, 120)
garbage_truck_image = garbage_truck_image.convert_alpha() garbage_truck_image = garbage_truck_image.convert_alpha()
garbage_truck_image = pygame.transform.scale(garbage_truck_image, new_garbage_truck_size) garbage_truck_image = pygame.transform.scale(garbage_truck_image, new_garbage_truck_size)
@ -26,13 +27,26 @@ for key in trash_can_images:
garbage_truck_position = [800, 500] garbage_truck_position = [800, 500]
trash_cans = [ trash_cans = [
{'position': [100, 100], 'type': 'paper'}, {'position': [1600, 300], 'type': 'paper'},
{'position': [1500, 800], 'type': 'metals_and_plastics'}, {'position': [1600, 500], 'type': 'metals_and_plastics'},
{'position': [750, 800], 'type': 'mixed'}, {'position': [1600, 700], 'type': 'mixed'},
{'position': [100, 800], 'type': 'bio_waste'}, {'position': [1600, 900], 'type': 'bio_waste'},
{'position': [1500, 100], 'type': 'glass'}, {'position': [1600, 100], 'type': 'glass'},
] ]
houses = []
house_positions = [[100, 200], [400, 400], [150, 600], [800, 800], [1000, 200], [1200, 700], [700, 100], [500, 800]]
for i in range(8):
house_image = pygame.image.load(f'house_{i}.jpg')
house_image = pygame.transform.scale(house_image, new_house_size)
house = {
'position': house_positions[i],
'image': house_image,
'trash_bin': []
}
houses.append(house)
running = True running = True
while running: while running:
for event in pygame.event.get(): for event in pygame.event.get():
@ -46,6 +60,8 @@ while running:
screen.blit(garbage_truck_image, garbage_truck_position) screen.blit(garbage_truck_image, garbage_truck_position)
for trash_can in trash_cans: for trash_can in trash_cans:
screen.blit(trash_can_images[trash_can['type']], trash_can['position']) screen.blit(trash_can_images[trash_can['type']], trash_can['position'])
for house in houses:
screen.blit(house['image'], house['position'])
pygame.display.flip() pygame.display.flip()