Madra_smieciarka/main.py
2024-03-10 18:04:48 +01:00

70 lines
2.2 KiB
Python

import pygame
import random
pygame.init()
screen = pygame.display.set_mode((1800, 1000))
garbage_truck_image = pygame.image.load('garbage_truck.png')
trash_can_images = {
'paper': pygame.image.load('trash_can_papier.jpg').convert_alpha(),
'metals_and_plastics': pygame.image.load('trash_can_metale_plastik.jpg').convert_alpha(),
'mixed': pygame.image.load('trash_can_zmieszane.jpg').convert_alpha(),
'bio_waste': pygame.image.load('trash_can_bio.jpg').convert_alpha(),
'glass': pygame.image.load('trash_can_szklo.jpg').convert_alpha(),
}
new_garbage_truck_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 = pygame.transform.scale(garbage_truck_image, new_garbage_truck_size)
for key in trash_can_images:
trash_can_images[key] = pygame.transform.scale(trash_can_images[key], new_trash_can_size)
garbage_truck_position = [800, 500]
trash_cans = [
{'position': [1600, 300], 'type': 'paper'},
{'position': [1600, 500], 'type': 'metals_and_plastics'},
{'position': [1600, 700], 'type': 'mixed'},
{'position': [1600, 900], 'type': 'bio_waste'},
{'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
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
garbage_truck_position[0] += random.randint(-4, 4)
garbage_truck_position[1] += random.randint(-4, 4)
screen.fill((255, 255, 255))
screen.blit(garbage_truck_image, garbage_truck_position)
for trash_can in trash_cans:
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.quit()