Madra_smieciarka/main.py

60 lines
1.9 KiB
Python
Raw Normal View History

2024-03-19 21:08:24 +01:00
from generators import *
import time
2024-03-10 14:32:06 +01:00
W = 30
H = 20
MULT = 50
SIZE = (MULT*W, MULT*H)
2024-03-10 14:32:06 +01:00
pygame.init()
2024-03-25 11:21:23 +01:00
screen = pygame.display.set_mode(SIZE)
tilemap = Tilemap(Tileset("sprites/TIles/1 Tiles/FieldsTile_38.png", mult=MULT), mult=MULT, size=(W, H))
targimage = pygame.image.load("sprites/X.png").convert_alpha()
targimage = pygame.transform.scale(targimage, (MULT, MULT))
2024-03-10 18:04:48 +01:00
trashcans = trashcanGenerator(MULT)
houses = householdGenerator(MULT)
garbagetruck = Garbagetruck(MULT).setHouses(houses).setTrashcans(trashcans)
2024-03-10 21:19:35 +01:00
print("Kolejność danych do drzewa:")
print("Pora roku - Pora dnia - Typ śmieci - Zapełnienie kosza - Zapełnienie śmieciarki - Zapłacone - Ostatnio zabrane "
"- Pogoda")
2024-03-10 14:32:06 +01:00
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
garbagetruck.setTarget()
garbagetruck.executeMovement()
2024-03-25 11:21:23 +01:00
screen.fill((0, 0, 0))
tilemap.render(MULT)
2024-03-25 11:21:23 +01:00
screen.blit(tilemap.image, tilemap.rect)
for i in trashcans:
screen.blit(i.getImage(), i.printme())
for h in houses:
screen.blit(h.getImage(), h.printme())
bruh = garbagetruck.target.getPosition()
bruhlist = [i*MULT for i in bruh]
screen.blit(targimage, bruhlist)
screen.blit(garbagetruck.getImage(), garbagetruck.printme())
2024-03-25 11:21:23 +01:00
pygame.display.update()
garbagetruck.scanTile()
state = garbagetruck.getState()
while garbagetruck.getAnalising():
garbagetruck.pickTrash()
if not garbagetruck.movesequence:
moves = garbagetruck.graphsearch()
garbagetruck.setMovesequence(moves)
if state:
if state.getFinal():
print([trash.getTtype() for trash in state.getGarbage().getContent()])
garbagetruck.switchAnalising()
garbagetruck.getState().switchFinal()
elif not garbagetruck.movesequence:
garbagetruck.randomTarget()
time.sleep(0.5)
2024-03-10 14:32:06 +01:00
pygame.quit()