classes.py removed, each class individually and file cleanup
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
|
25
classes/Household.py
Normal file
@ -0,0 +1,25 @@
|
||||
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
|
17
classes/Junkyard.py
Normal file
@ -0,0 +1,17 @@
|
||||
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
|
23
classes/Tile.py
Normal file
@ -0,0 +1,23 @@
|
||||
class Tile:
|
||||
def __init__(self):
|
||||
self.position = None
|
||||
self.sprite = None
|
||||
self.parent = None
|
||||
|
||||
def getSprite(self):
|
||||
return self.sprite
|
||||
|
||||
def setSprite(self, sprite):
|
||||
self.sprite = sprite
|
||||
|
||||
def getPosition(self):
|
||||
return self.position
|
||||
|
||||
def setPosition(self, position):
|
||||
self.position = position
|
||||
|
||||
def getParent(self):
|
||||
return self.parent
|
||||
|
||||
def setParent(self, parent):
|
||||
self.parent = parent
|
29
classes/Trashcan.py
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
19
main.py
@ -1,6 +1,7 @@
|
||||
import pygame
|
||||
import random
|
||||
from classes import *
|
||||
from classes.Trashcan import *
|
||||
from classes.Junkyard import *
|
||||
from classes.Household import *
|
||||
from QOLfunc import *
|
||||
|
||||
pygame.init()
|
||||
@ -12,14 +13,14 @@ colors = {
|
||||
"red": (255, 0, 0)
|
||||
}
|
||||
|
||||
garbage_truck_image = pygame.image.load('garbage_truck.png')
|
||||
garbage_truck_image = pygame.image.load('sprites/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(),
|
||||
'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(),
|
||||
}
|
||||
|
||||
new_garbage_truck_size = (120, 120)
|
||||
@ -60,7 +61,7 @@ for i in range(8):
|
||||
houses.append(house)
|
||||
|
||||
for i in range(len(houses)):
|
||||
if i%2 == 0:
|
||||
if i % 2 == 0:
|
||||
neigh = chooseNeighbours(2, i)
|
||||
else:
|
||||
neigh = chooseNeighbours(3, i)
|
||||
|
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 |