Merge pull request 'Reprezentacja wiedzy' (#3) from premain into main
Reviewed-on: #3
20
QOLfunc.py
@ -1,17 +1,9 @@
|
||||
# Tutaj wrzucam jakieś funkcje różne, co by nie zaśmiecać tym maina jak nie trzeba
|
||||
from classes.Household import *
|
||||
|
||||
import random
|
||||
colors = {
|
||||
"white": (255, 255, 255),
|
||||
"black": (0, 0, 0),
|
||||
"red": (255, 0, 0)
|
||||
}
|
||||
|
||||
|
||||
def chooseNeighbours(count: int, i: int) -> set:
|
||||
"""
|
||||
:param count: ile sąsiadów ma wybrać
|
||||
:param i: id obiektu, żeby nie był sąsiadem sam ze sobą
|
||||
:return: zbiór id wybranych losowo sąsiadów obiektu
|
||||
"""
|
||||
neigh = set()
|
||||
while len(neigh) < count:
|
||||
num = random.randint(0, 7)
|
||||
if num != i:
|
||||
neigh.add(num)
|
||||
return neigh
|
||||
|
77
classes.py
@ -1,77 +0,0 @@
|
||||
# Robię to wszystko jako obiekty, bo tak później będzie łątwiej dodawać do nich rzeczy, niż przerabiać słowniki
|
||||
|
||||
class Trashcan:
|
||||
def __init__(self, id, image, position, trashtype):
|
||||
self.id = id
|
||||
self.image = image
|
||||
assert isinstance(position, tuple)
|
||||
self.position = position
|
||||
self.type = trashtype
|
||||
self.neighbours = []
|
||||
|
||||
def setNeighbours(self, neighbours):
|
||||
self.neighbours = neighbours
|
||||
|
||||
def addNeighbour(self, neighbour):
|
||||
self.neighbours.append(neighbour)
|
||||
|
||||
def getNeighbours(self):
|
||||
return self.neighbours
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def getImage(self):
|
||||
return self.image
|
||||
|
||||
def getType(self):
|
||||
return self.type
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
|
||||
class Household:
|
||||
def __init__(self, id, image, position):
|
||||
self.id = id
|
||||
self.image = image
|
||||
assert isinstance(position, tuple)
|
||||
self.position = position
|
||||
self.neighbours = []
|
||||
|
||||
def setNeighbours(self, neighbours):
|
||||
self.neighbours = neighbours
|
||||
|
||||
def addNeighbour(self, neighbour):
|
||||
self.neighbours.append(neighbour)
|
||||
|
||||
def getNeighbours(self):
|
||||
return self.neighbours
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def getImage(self):
|
||||
return self.image
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
|
||||
class Junkyard:
|
||||
def __init__(self):
|
||||
self.id = 0
|
||||
self.position = (1400, 500)
|
||||
self.neighbours = []
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def addNeighbour(self, neighbour):
|
||||
self.neighbours.append(neighbour)
|
||||
|
||||
def getNeighbours(self):
|
||||
return self.neighbours
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
62
classes/Garbage.py
Normal file
@ -0,0 +1,62 @@
|
||||
import random
|
||||
from classes.Trash import *
|
||||
|
||||
|
||||
class Garbage:
|
||||
def __init__(self):
|
||||
self.content = []
|
||||
self.predict = []
|
||||
self.prob: float = 0.3
|
||||
self.generatePredict()
|
||||
self.generateContent()
|
||||
self.predict = tuple(self.predict)
|
||||
|
||||
def getContent(self):
|
||||
return self.content
|
||||
|
||||
def setContent(self, content):
|
||||
self.content = content
|
||||
return self
|
||||
|
||||
def addContent(self, item: Trash):
|
||||
self.content.append(item)
|
||||
return self
|
||||
|
||||
def removeContent(self, item: int):
|
||||
return self.content.pop(item)
|
||||
|
||||
def getPredict(self):
|
||||
return self.predict
|
||||
|
||||
def setPredict(self, predict):
|
||||
self.predict = predict
|
||||
return self
|
||||
|
||||
def addPredict(self, item):
|
||||
self.predict.append(item)
|
||||
return self
|
||||
|
||||
def getProb(self):
|
||||
return self.prob
|
||||
|
||||
def setProb(self, prob):
|
||||
self.prob = prob
|
||||
return self
|
||||
|
||||
def generatePredict(self, i=random.choice([2, 3])):
|
||||
if i < 0:
|
||||
self.predict.pop(i)
|
||||
else:
|
||||
for _ in range(i):
|
||||
possible = [Papier(), MetalPlastik(), Szklo(), Mixed(), Bio()]
|
||||
traf = random.choice(possible)
|
||||
self.predict.append(traf)
|
||||
for bruh in possible:
|
||||
if bruh != traf:
|
||||
del bruh
|
||||
|
||||
def generateContent(self):
|
||||
self.setContent(self.predict[:])
|
||||
if random.random() < self.prob:
|
||||
mod = random.choice([1, -1])
|
||||
self.generatePredict(mod)
|
148
classes/Garbagetruck.py
Normal file
@ -0,0 +1,148 @@
|
||||
import pygame
|
||||
from classes.Household import *
|
||||
from classes.Trashcan import *
|
||||
|
||||
|
||||
class Garbagetruck:
|
||||
|
||||
def __init__(self):
|
||||
self.capacity: int = 20
|
||||
self.trash: list = []
|
||||
self.trashweight: int = 0
|
||||
self.image = pygame.image.load("sprites/garbage_truck.png").convert_alpha()
|
||||
self.image = pygame.transform.scale(self.image, (32, 32))
|
||||
self.position = [3, 3]
|
||||
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 getRunningtime(self):
|
||||
return self.runningtime
|
||||
|
||||
def setRunningtime(self, runningtime):
|
||||
self.runningtime = runningtime
|
||||
return self
|
||||
|
||||
def incrRunningtime(self):
|
||||
self.runningtime += 1
|
||||
return self
|
||||
|
||||
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
|
||||
|
||||
def getTrash(self) -> list:
|
||||
return self.trash
|
||||
|
||||
def setTrash(self, trash: list) -> None:
|
||||
self.trash = trash
|
||||
for item in trash:
|
||||
self.addTrashweight(item.getWaga)
|
||||
|
||||
def addTrash(self, trash: Trash) -> None:
|
||||
self.trash.append(trash)
|
||||
self.addTrashweight(trash.getWaga())
|
||||
|
||||
def getTrashweight(self) -> int:
|
||||
return self.trashweight
|
||||
|
||||
def setTrashweight(self, weight: int) -> None:
|
||||
self.trashweight = weight
|
||||
|
||||
def addTrashweight(self, weight: int) -> None:
|
||||
self.trashweight += weight
|
||||
|
||||
def getImage(self) -> object:
|
||||
return self.image
|
||||
|
||||
def setImage(self, image: object) -> None:
|
||||
self.image = image
|
||||
|
||||
def getPosition(self) -> list:
|
||||
return self.position
|
||||
|
||||
def setPosition(self, position: list) -> object:
|
||||
self.position = position
|
||||
return self
|
||||
|
||||
def modPosiotion(self, modX, modY):
|
||||
x = self.getPosition()[0] + modX
|
||||
y = self.getPosition()[1] + modY
|
||||
self.setPosition([x, y])
|
||||
|
||||
def getRoute(self):
|
||||
return self.route
|
||||
|
||||
def setRoute(self, route) -> None:
|
||||
self.route = route
|
||||
|
||||
def getScanner(self):
|
||||
return self.scanner
|
||||
|
||||
def setScanner(self, scanner) -> None:
|
||||
self.route = scanner
|
||||
|
||||
def getPlanner(self):
|
||||
return self.planner
|
||||
|
||||
def setPlanner(self, planner) -> None:
|
||||
self.route = planner
|
||||
|
||||
def getDriver(self):
|
||||
return self.driver
|
||||
|
||||
def setDriver(self, driver) -> None:
|
||||
self.route = driver
|
||||
|
||||
def distance(self, object1, object2) -> int:
|
||||
lok1 = object1.getPosition()
|
||||
lok2 = object2.getPosition()
|
||||
|
||||
dist = abs(lok1[0] - lok2[0]) + abs(lok1[1] - lok2[1])
|
||||
return dist
|
||||
|
||||
def scanTile(self):
|
||||
self.state = None
|
||||
temp = self.houses[:]
|
||||
temp.append(self.trashcans[:])
|
||||
for loc in temp:
|
||||
if tuple(self.position) == loc.getPosition():
|
||||
self.state = loc
|
||||
return
|
||||
|
||||
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
|
53
classes/Household.py
Normal file
@ -0,0 +1,53 @@
|
||||
from classes.Garbage import *
|
||||
|
||||
|
||||
class Household:
|
||||
def __init__(self):
|
||||
self.id: int = 0
|
||||
self.image: object = None
|
||||
self.position: tuple = None
|
||||
self.garbage: object = Garbage()
|
||||
|
||||
def setPosition(self, position: tuple):
|
||||
self.position = position
|
||||
return self
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def setImage(self, image: object):
|
||||
self.image = image
|
||||
return self
|
||||
|
||||
def getImage(self):
|
||||
return self.image
|
||||
|
||||
def setId(self, newID: int):
|
||||
self.id = newID
|
||||
return self
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def setGarbage(self, garbage: object):
|
||||
self.garbage = garbage
|
||||
return self
|
||||
|
||||
def getGarbage(self):
|
||||
return self.garbage
|
||||
|
||||
def printme(self):
|
||||
x, y = self.getPosition()
|
||||
return 32*x, 32*y
|
||||
|
||||
|
||||
def generateHousehold(i, image, position):
|
||||
"""
|
||||
:param int i:
|
||||
:param object image:
|
||||
:param tuple position:
|
||||
:return:
|
||||
"""
|
||||
house = Household()
|
||||
house.setId(i).setImage(image).setPosition(position)
|
||||
return house
|
35
classes/Tilemap.py
Normal file
@ -0,0 +1,35 @@
|
||||
import pygame
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Tilemap:
|
||||
|
||||
def __init__(self, tileset, size=(30, 20), rect=None):
|
||||
self.size = size
|
||||
self.tileset = tileset
|
||||
self.map = np.zeros(size, dtype=int)
|
||||
w, h = self.size
|
||||
self.image = pygame.Surface((32*w, 32*h))
|
||||
if rect:
|
||||
self.rect = pygame.Rect(rect)
|
||||
else:
|
||||
self.rect = self.image.get_rect()
|
||||
|
||||
def render(self):
|
||||
m, n = self.map.shape
|
||||
for i in range(m):
|
||||
for j in range(n):
|
||||
tile = self.tileset.tiles[self.map[i, j]]
|
||||
self.image.blit(tile, (i*32, j*32))
|
||||
|
||||
def set_zero(self):
|
||||
self.map = np.zeros(self.size, dtype=int)
|
||||
self.render()
|
||||
|
||||
def set_random(self):
|
||||
n = len(self.tileset.tiles)
|
||||
self.map = np.random.randint(n, size=self.size)
|
||||
self.render()
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.__class__.__name__} {self.size}'
|
29
classes/Tileset.py
Normal file
@ -0,0 +1,29 @@
|
||||
import pygame
|
||||
|
||||
|
||||
class Tileset:
|
||||
|
||||
def __init__(self, file, size=(32, 32), margin=1, spacing=1):
|
||||
self.file = file
|
||||
self.size = size
|
||||
self.margin = margin
|
||||
self.spacing = spacing
|
||||
self.image = pygame.image.load(file)
|
||||
self.rect = self.image.get_rect()
|
||||
self.tiles = []
|
||||
self.load()
|
||||
|
||||
def load(self):
|
||||
self.tiles = []
|
||||
x0 = y0 = self.margin
|
||||
w, h = self.rect.size
|
||||
dx = self.size[0] + self.spacing
|
||||
dy = self.size[1] + self.spacing
|
||||
for x in range(x0, w, dx):
|
||||
for y in range(y0, h, dy):
|
||||
tile = pygame.Surface(self.size)
|
||||
tile.blit(self.image, (0, 0), (x, y, *self.size))
|
||||
self.tiles.append(tile)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.__class__.__name__} file:{self.file} tile:{self.size}'
|
60
classes/Trash.py
Normal file
@ -0,0 +1,60 @@
|
||||
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
|
||||
|
||||
def setWaga(self, waga):
|
||||
self.waga = waga
|
||||
return self
|
||||
|
||||
def getImage(self):
|
||||
return self.image
|
||||
|
||||
def setImage(self, image):
|
||||
self.image = image
|
||||
return self
|
||||
|
||||
|
||||
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
|
51
classes/Trashcan.py
Normal file
@ -0,0 +1,51 @@
|
||||
class Trashcan:
|
||||
def __init__(self):
|
||||
self.id: int = 0
|
||||
self.image: object = None
|
||||
self.position: tuple = None
|
||||
self.trashtype: str = None
|
||||
|
||||
def setPosition(self, position: tuple):
|
||||
self.position = position
|
||||
return self
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def setImage(self, image: object):
|
||||
self.image = image
|
||||
return self
|
||||
|
||||
def getImage(self):
|
||||
return self.image
|
||||
|
||||
def setTrashtype(self, trashtype: str):
|
||||
self.trashtype = trashtype
|
||||
return self
|
||||
|
||||
def getTrashtype(self):
|
||||
return self.trashtype
|
||||
|
||||
def setId(self, newId: int):
|
||||
self.id = newId
|
||||
return self
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def printme(self):
|
||||
x, y = self.getPosition()
|
||||
return 32*x, 32*y
|
||||
|
||||
|
||||
def generateTrashcan(newId, image, position, trashtype):
|
||||
"""
|
||||
:param int newId:
|
||||
:param string image:
|
||||
:param tuple position:
|
||||
:param string trashtype:
|
||||
:return object Trashcan:
|
||||
"""
|
||||
trash = Trashcan()
|
||||
trash.setId(newId).setImage(image).setPosition(position).setTrashtype(trashtype)
|
||||
return trash
|
46
generators.py
Normal file
@ -0,0 +1,46 @@
|
||||
from classes.Trashcan import *
|
||||
from classes.Household import *
|
||||
from classes.Garbagetruck import *
|
||||
from classes.Tilemap import *
|
||||
from classes.Tileset import *
|
||||
from QOLfunc import *
|
||||
import pygame
|
||||
|
||||
|
||||
def trashcanGenerator() -> list:
|
||||
typelist = ["paper", "metals_and_plastics", "mixed", "bio_waste", "glass"]
|
||||
trash_cans = [
|
||||
{'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'},
|
||||
]
|
||||
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], (32,32))
|
||||
for i in range(5):
|
||||
trashcan = generateTrashcan(i, trash_can_images[typelist[i]], trash_cans[i]["position"], trash_cans[i]["type"])
|
||||
trashcans.append(trashcan)
|
||||
|
||||
return trashcans
|
||||
|
||||
|
||||
def householdGenerator():
|
||||
new_house_size = (32, 32)
|
||||
house_positions = [(15, 5), (17, 5), (19, 5), (21, 5), (15, 8), (17, 8), (19, 8), (21, 8)]
|
||||
houses = []
|
||||
for i in range(8):
|
||||
house_image = pygame.image.load(f'sprites/domek.png')
|
||||
house_image = pygame.transform.scale(house_image, new_house_size)
|
||||
house = generateHousehold(i, house_image, house_positions[i])
|
||||
houses.append(house)
|
||||
|
||||
return houses
|
107
main.py
@ -1,76 +1,16 @@
|
||||
import pygame
|
||||
import random
|
||||
from classes import *
|
||||
from QOLfunc import *
|
||||
from generators import *
|
||||
|
||||
W = 30
|
||||
H = 20
|
||||
MULT = 32
|
||||
SIZE = (MULT*W, MULT*H)
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((1800, 1000))
|
||||
screen = pygame.display.set_mode(SIZE)
|
||||
tilemap = Tilemap(Tileset("sprites/Tiles/1 Tiles/FieldsTile_38.png"), (W, H))
|
||||
|
||||
colors = {
|
||||
"white": (255, 255, 255),
|
||||
"black": (0, 0, 0),
|
||||
"red": (255, 0, 0)
|
||||
}
|
||||
|
||||
garbage_truck_image = pygame.image.load('garbage_truck.png')
|
||||
|
||||
trash_can_images = {
|
||||
'paper': pygame.image.load('trash_can_papier.jpg').convert_alpha(),
|
||||
'metals_and_plastics': pygame.image.load('trash_can_metale_plastik.jpg').convert_alpha(),
|
||||
'mixed': pygame.image.load('trash_can_zmieszane.jpg').convert_alpha(),
|
||||
'bio_waste': pygame.image.load('trash_can_bio.jpg').convert_alpha(),
|
||||
'glass': pygame.image.load('trash_can_szklo.jpg').convert_alpha(),
|
||||
}
|
||||
|
||||
new_garbage_truck_size = (120, 120)
|
||||
new_trash_can_size = (90, 90)
|
||||
new_house_size = (140, 120)
|
||||
|
||||
garbage_truck_image = garbage_truck_image.convert_alpha()
|
||||
garbage_truck_image = pygame.transform.scale(garbage_truck_image, new_garbage_truck_size)
|
||||
|
||||
for key in trash_can_images:
|
||||
trash_can_images[key] = pygame.transform.scale(trash_can_images[key], new_trash_can_size)
|
||||
|
||||
garbage_truck_position = [800, 500]
|
||||
|
||||
trash_cans = [
|
||||
{'position': (1600, 300), 'type': 'paper'},
|
||||
{'position': (1600, 500), 'type': 'metals_and_plastics'},
|
||||
{'position': (1600, 700), 'type': 'mixed'},
|
||||
{'position': (1600, 900), 'type': 'bio_waste'},
|
||||
{'position': (1600, 100), 'type': 'glass'},
|
||||
]
|
||||
junkyard = Junkyard()
|
||||
trashcans = []
|
||||
typelist = ["paper", "metals_and_plastics", "mixed", "bio_waste", "glass"]
|
||||
for i in range(5):
|
||||
trashcan = Trashcan(i, trash_can_images[typelist[i]], trash_cans[i]["position"], trash_cans[i]["type"])
|
||||
trashcan.addNeighbour(junkyard)
|
||||
junkyard.addNeighbour(trashcan)
|
||||
trashcans.append(trashcan)
|
||||
|
||||
houses = []
|
||||
house_positions = [(450, 100), (250, 250), (200, 700), (850, 800), (1000, 200), (1050, 700), (800, 100), (400, 850)]
|
||||
|
||||
for i in range(8):
|
||||
house_image = pygame.image.load(f'house_{i}.jpg')
|
||||
house_image = pygame.transform.scale(house_image, new_house_size)
|
||||
house = Household(i, house_image, house_positions[i])
|
||||
houses.append(house)
|
||||
|
||||
for i in range(len(houses)):
|
||||
if i%2 == 0:
|
||||
neigh = chooseNeighbours(2, i)
|
||||
else:
|
||||
neigh = chooseNeighbours(3, i)
|
||||
for num in neigh:
|
||||
if len(houses[i].getNeighbours()) < 3 and len(houses[num].getNeighbours()) < 3:
|
||||
houses[i].addNeighbour(houses[num])
|
||||
houses[num].addNeighbour(houses[i])
|
||||
if i == 7 or i == 1:
|
||||
houses[i].addNeighbour(junkyard)
|
||||
junkyard.addNeighbour(houses[i])
|
||||
trashcans = trashcanGenerator()
|
||||
houses = householdGenerator()
|
||||
garbagetruck = Garbagetruck().setHouses(houses).setTrashcans(trashcans)
|
||||
|
||||
running = True
|
||||
while running:
|
||||
@ -78,23 +18,14 @@ while running:
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
|
||||
# garbage_truck_position[0] += random.randint(-4, 4)
|
||||
# garbage_truck_position[1] += random.randint(-4, 4)
|
||||
|
||||
screen.fill(colors["white"])
|
||||
for trash_can in trashcans:
|
||||
for neighbour in trash_can.getNeighbours():
|
||||
pygame.draw.line(screen, colors["black"], trash_can.getPosition(), neighbour.getPosition(), 3)
|
||||
screen.blit(trash_can.getImage(), trash_can.getPosition())
|
||||
for house in houses:
|
||||
for neighbour in house.getNeighbours():
|
||||
if neighbour.getId() < house.getId():
|
||||
pygame.draw.line(screen, colors["black"], house.getPosition(), neighbour.getPosition(), 3)
|
||||
for house in houses:
|
||||
screen.blit(house.getImage(), house.getPosition())
|
||||
pygame.draw.circle(screen, colors["red"], junkyard.getPosition(), 10)
|
||||
|
||||
screen.blit(garbage_truck_image, junkyard.getPosition())
|
||||
pygame.display.flip()
|
||||
screen.fill((0, 0, 0))
|
||||
tilemap.render()
|
||||
screen.blit(tilemap.image, tilemap.rect)
|
||||
screen.blit(garbagetruck.getImage(), garbagetruck.printme())
|
||||
for i in trashcans:
|
||||
screen.blit(i.getImage(), i.printme())
|
||||
for h in houses:
|
||||
screen.blit(h.getImage(), h.printme())
|
||||
pygame.display.update()
|
||||
|
||||
pygame.quit()
|
||||
|
BIN
sprites/domek.png
Normal file
After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 362 KiB After Width: | Height: | Size: 362 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 238 KiB After Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 230 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |