55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
import pygame.transform
|
|
|
|
from generators import *
|
|
import time
|
|
|
|
W = 30
|
|
H = 20
|
|
MULT = 50
|
|
SIZE = (MULT*W, MULT*H)
|
|
pygame.init()
|
|
screen = pygame.display.set_mode(SIZE)
|
|
tilemap = Tilemap(Tileset("sprites/TIles/1Tiles/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)
|
|
|
|
running = True
|
|
while running:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
|
|
print(garbagetruck.movesequence)
|
|
garbagetruck.setTarget()
|
|
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())
|
|
print(garbagetruck.getPosition())
|
|
bruh = garbagetruck.target.getPosition()
|
|
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()
|
|
if not garbagetruck.movesequence:
|
|
moves = garbagetruck.graphsearch()
|
|
garbagetruck.setMovesequence(moves)
|
|
if state:
|
|
if state.getFinal():
|
|
garbagetruck.getState().switchFinal()
|
|
elif not garbagetruck.movesequence:
|
|
garbagetruck.randomTarget()
|
|
time.sleep(0.5)
|
|
|
|
|
|
pygame.quit() |