Madra_smieciarka/generators.py

59 lines
2.1 KiB
Python
Raw Permalink Normal View History

2024-03-19 21:08:24 +01:00
from classes.Trashcan import *
from classes.Household import *
2024-03-25 00:05:56 +01:00
from classes.Garbagetruck import *
2024-03-25 11:21:23 +01:00
from classes.Tilemap import *
from classes.Tileset import *
2024-03-19 21:08:24 +01:00
from QOLfunc import *
import pygame
def trashcanGenerator(mult) -> list:
2024-03-19 21:08:24 +01:00
typelist = ["paper", "metals_and_plastics", "mixed", "bio_waste", "glass"]
trash_cans = [
2024-03-25 11:21:23 +01:00
{'position': (1, 0), 'type': 'paper'},
{'position': (1, 1), 'type': 'metals_and_plastics'},
{'position': (1, 2), 'type': 'mixed'},
{'position': (1, 3), 'type': 'bio_waste'},
{'position': (1, 4), 'type': 'glass'},
2024-03-19 21:08:24 +01:00
]
trash_can_images = {
'paper': pygame.image.load('sprites/trash_can_papier.jpg').convert_alpha(),
'metals_and_plastics': pygame.image.load('sprites/trash_can_metale_plastik.jpg').convert_alpha(),
'mixed': pygame.image.load('sprites/trash_can_zmieszane.jpg').convert_alpha(),
'bio_waste': pygame.image.load('sprites/trash_can_bio.jpg').convert_alpha(),
'glass': pygame.image.load('sprites/trash_can_szklo.jpg').convert_alpha(),
}
trashcans = []
for key in trash_can_images:
trash_can_images[key] = pygame.transform.scale(trash_can_images[key], (mult, mult))
2024-03-19 21:08:24 +01:00
for i in range(5):
trashcan = generateTrashcan(mult, i, trash_can_images[typelist[i]], trash_cans[i]["position"],
trash_cans[i]["type"])
2024-03-19 21:08:24 +01:00
trashcans.append(trashcan)
return trashcans
def householdGenerator(mult):
new_house_size = (mult, mult)
temp = []
for i in range(1, 29):
if i % 2 == 1:
temp.append((i, 6))
temp.append((i, 12))
elif i % 2 == 0:
temp.append((i, 9))
if i % 2 == 1 and i % 4 != 1:
temp.append((i, 10))
house_positions = temp
2024-03-19 21:08:24 +01:00
houses = []
for i in range(len(house_positions)):
house_image = pygame.image.load(f'sprites/domek.png')
2024-03-19 21:08:24 +01:00
house_image = pygame.transform.scale(house_image, new_house_size)
house = generateHousehold(mult, i, house_image, house_positions[i])
if i == 1:
house.switchFinal()
2024-03-19 21:08:24 +01:00
houses.append(house)
return houses