Dobra chyba jest wystarczająco na teraz
Signed-off-by: Neerka <jakub.markil1@gmail.com>
This commit is contained in:
parent
e02adf16b6
commit
8d39c1f1a0
@ -7,9 +7,3 @@ colors = {
|
||||
"red": (255, 0, 0)
|
||||
}
|
||||
|
||||
def allLocations(*lista):
|
||||
final = set()
|
||||
for _ in lista:
|
||||
for item in _:
|
||||
final.add(item)
|
||||
return final
|
||||
|
@ -12,27 +12,44 @@ class Garbagetruck:
|
||||
self.image = pygame.image.load(file).convert_alpha()
|
||||
self.image = pygame.transform.scale(self.image, (32, 32))
|
||||
self.position = [3, 3]
|
||||
self.predicts: set = set()
|
||||
self.others: set = set()
|
||||
self.state = 0
|
||||
self.houses: list = []
|
||||
self.trashcans: list = []
|
||||
self.state = None
|
||||
self.segregation = {"Papier": "paper",
|
||||
"MetalPlastik": "metals_and_plastics",
|
||||
"Mixed": "mixed",
|
||||
"Bio": "bio_waste",
|
||||
"Szklo": "glass"}
|
||||
self.route = None
|
||||
self.scanner = None
|
||||
self.planner = None
|
||||
self.driver = None
|
||||
self.runningtime = 0
|
||||
|
||||
def getOthers(self):
|
||||
return self.others
|
||||
def getRunningtime(self):
|
||||
return self.runningtime
|
||||
|
||||
def setOthers(self, others):
|
||||
self.others = others
|
||||
def setRunningtime(self, runningtime):
|
||||
self.runningtime = runningtime
|
||||
return self
|
||||
|
||||
def setPredicts(self, predicts):
|
||||
self.predicts = predicts
|
||||
def incrRunningtime(self):
|
||||
self.runningtime += 1
|
||||
return self
|
||||
|
||||
def getPredicts(self):
|
||||
return self.predicts
|
||||
def getTrashcans(self):
|
||||
return self.trashcans
|
||||
|
||||
def setTrashcans(self, others):
|
||||
self.trashcans = others
|
||||
return self
|
||||
|
||||
def setHouses(self, houses):
|
||||
self.houses = houses
|
||||
return self
|
||||
|
||||
def getHouses(self):
|
||||
return self.houses
|
||||
|
||||
def getCapacity(self) -> int:
|
||||
return self.capacity
|
||||
@ -49,11 +66,6 @@ class Garbagetruck:
|
||||
self.trash.append(trash)
|
||||
self.addTrashweight(trash.getWaga())
|
||||
|
||||
def removeTrash(self, trashid: int) -> object:
|
||||
trash = self.trash.pop(trashid)
|
||||
self.addTrashweight(trash.getWeight * (-1))
|
||||
return trash
|
||||
|
||||
def getTrashweight(self) -> int:
|
||||
return self.trashweight
|
||||
|
||||
@ -113,8 +125,10 @@ class Garbagetruck:
|
||||
return dist
|
||||
|
||||
def scanTile(self):
|
||||
self.state = 0
|
||||
for loc in self.others:
|
||||
self.state = None
|
||||
temp = self.houses[:]
|
||||
temp.append(self.trashcans[:])
|
||||
for loc in temp:
|
||||
if tuple(self.position) == loc.getPosition():
|
||||
self.state = loc
|
||||
return
|
||||
@ -122,3 +136,13 @@ class Garbagetruck:
|
||||
def printme(self):
|
||||
x, y = self.getPosition()
|
||||
return 32*x, 32*y
|
||||
|
||||
def throwGarbage(self, trash):
|
||||
if self.segregation[trash.getTtype()] == self.state.getTrashtype():
|
||||
self.addTrashweight(trash.getWeight * (-1))
|
||||
self.trash.remove(trash)
|
||||
|
||||
def classifyTrash(self):
|
||||
pass
|
||||
# Tutaj jest plan żeby dopiero napisać funkcję jak już będzie klasyfikator
|
||||
# ogólnie to myślałem żeby po prostu zklasyfikować śmieć i zmienić mu trashtype na rozpoznany, żeby śmieciarka go tak posegreowała
|
||||
|
@ -3,6 +3,13 @@ typelist = ["paper", "metals_and_plastics", "mixed", "bio_waste", "glass"]
|
||||
|
||||
class Trash:
|
||||
|
||||
def getTtype(self):
|
||||
return self.ttype
|
||||
|
||||
def setTtype(self, ttype):
|
||||
self.ttype = ttype
|
||||
return self
|
||||
|
||||
def getWaga(self):
|
||||
return self.waga
|
||||
|
||||
@ -20,29 +27,34 @@ class Trash:
|
||||
|
||||
class Papier(Trash):
|
||||
def __init__(self):
|
||||
self.ttype = "Papier"
|
||||
self.waga = 2
|
||||
self.image = None
|
||||
|
||||
|
||||
class MetalPlastik(Trash):
|
||||
def __init__(self):
|
||||
self.ttype = "MetalPlastik"
|
||||
self.waga = 3
|
||||
self.image = None
|
||||
|
||||
|
||||
class Mixed(Trash):
|
||||
def __init__(self):
|
||||
self.ttype = "Mixed"
|
||||
self.waga = 1
|
||||
self.image = None
|
||||
|
||||
|
||||
class Bio(Trash):
|
||||
def __init__(self):
|
||||
self.ttype = "Bio"
|
||||
self.waga = 2
|
||||
self.image = None
|
||||
|
||||
|
||||
class Szklo(Trash):
|
||||
def __init__(self):
|
||||
self.ttype = "Szklo"
|
||||
self.waga = 5
|
||||
self.image = None
|
||||
|
2
main.py
2
main.py
@ -10,7 +10,7 @@ tilemap = Tilemap(Tileset("sprites/Tiles/1 Tiles/FieldsTile_38.png"), (W, H))
|
||||
|
||||
trashcans = trashcanGenerator()
|
||||
houses = householdGenerator()
|
||||
garbagetruck = Garbagetruck().setPredicts(houses).setOthers(allLocations(trashcans, houses))
|
||||
garbagetruck = Garbagetruck().setHouses(houses).setTrashcans(trashcans)
|
||||
|
||||
running = True
|
||||
while running:
|
||||
|
BIN
sprites/domek.png
Normal file
BIN
sprites/domek.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
25
tests.py
25
tests.py
@ -1,25 +0,0 @@
|
||||
from classes.Tilemap import *
|
||||
from classes.Tileset import *
|
||||
|
||||
W = 960
|
||||
H = 640
|
||||
SIZE = (W, H)
|
||||
|
||||
pygame.init()
|
||||
|
||||
screen = pygame.display.set_mode(SIZE)
|
||||
pygame.display.set_caption("Tilemap Demo")
|
||||
tilemap = Tilemap(Tileset("sprites/Tiles/1 Tiles/FieldsTile_38.png"), (30, 20))
|
||||
|
||||
running = True
|
||||
while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
|
||||
screen.fill((0, 0, 0))
|
||||
tilemap.render()
|
||||
screen.blit(tilemap.image, tilemap.rect)
|
||||
pygame.display.update()
|
||||
|
||||
pygame.quit()
|
Loading…
Reference in New Issue
Block a user