import time import classes.Household from generators import * W = 30 H = 20 MULT = 50 SIZE = (MULT*W, MULT*H) pygame.init() 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)) trashcans = trashcanGenerator(MULT) houses = householdGenerator(MULT) garbagetruck = Garbagetruck(MULT).setHouses(houses).setTrashcans(trashcans) garbagetruck.setFirstTarget() # print("Kolejność danych do drzewa:") # print("Pora roku - Pora dnia - Typ śmieci - Zapełnienie kosza - Zapełnienie śmieciarki - Zapłacone - Ostatnio zabrane " # "- Pogoda") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False garbagetruck.executeMovement() screen.fill((0, 0, 0)) tilemap.render(MULT) 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 bruhlist = [i*MULT for i in bruh] screen.blit(targimage, bruhlist) screen.blit(garbagetruck.getImage(), garbagetruck.printme()) pygame.display.update() garbagetruck.scanTile() state = garbagetruck.getState() garbagetruck.goDumpTrash() # print(type(state)) while garbagetruck.getAnalising(): garbagetruck.pickTrash() if not garbagetruck.movesequence: moves = garbagetruck.graphsearch() garbagetruck.setMovesequence(moves) if state: if isinstance(state, classes.Household.Household) and state.getFinal(): # print([trash.getTtype() for trash in state.getGarbage().getContent()]) garbagetruck.switchAnalising() garbagetruck.getState().switchFinal() elif isinstance(state, classes.Trashcan.Trashcan) and state.getFinal(): print("Wyrzucam") garbagetruck.throwGarbage() print([trash.getTtype() for trash in garbagetruck.getTrash()]) garbagetruck.getState().switchFinal() if not garbagetruck.movesequence and not garbagetruck.getAnalising(): garbagetruck.setTarget() time.sleep(0.25) pygame.quit()