Madra_smieciarka/main.py

54 lines
1.7 KiB
Python
Raw Normal View History

2024-03-10 14:32:06 +01:00
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 = (120, 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': [100, 100], 'type': 'paper'},
{'position': [1500, 800], 'type': 'metals_and_plastics'},
{'position': [750, 800], 'type': 'mixed'},
{'position': [100, 800], 'type': 'bio_waste'},
{'position': [1500, 100], 'type': 'glass'},
]
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'])
pygame.display.flip()
pygame.quit()