2019-03-19 11:47:23 +01:00
|
|
|
import pygame
|
2019-03-19 18:10:04 +01:00
|
|
|
import sys, random
|
2019-03-19 11:47:23 +01:00
|
|
|
from sprites.cell import Cell
|
|
|
|
|
2019-03-19 18:10:04 +01:00
|
|
|
PLASTIC = 0 #blue
|
|
|
|
GLASS = 1 #green
|
|
|
|
METAL = 2 #yellow
|
|
|
|
|
2019-03-19 11:47:23 +01:00
|
|
|
class House(Cell):
|
2019-03-19 18:10:04 +01:00
|
|
|
def __init__(self,x,y, max_plastic, max_glass, max_metal):
|
|
|
|
Cell.__init__(self,x,y)
|
|
|
|
self.image = pygame.image.load("images/house.png")
|
|
|
|
self.rubbish = [0,0,0] #plastic, glass, metal
|
|
|
|
|
|
|
|
self.max_plastic = max_plastic
|
|
|
|
self.max_glass = max_glass
|
|
|
|
self.max_metal = max_metal
|
|
|
|
|
|
|
|
def generate_rubbish(self):
|
|
|
|
if( random.randint(0, 5) == 1 ): #1/5 szansa na wyrzucenie śmiecia w klatce
|
|
|
|
thrash_type = random.randint(0,2)
|
|
|
|
self.rubbish[thrash_type] = self.rubbish[thrash_type] + 1
|
|
|
|
|
|
|
|
if( self.rubbish[PLASTIC] > self.max_plastic ):
|
2019-03-19 18:34:10 +01:00
|
|
|
self.image = pygame.image.load("images/house_plastic.png")
|
2019-03-19 18:10:04 +01:00
|
|
|
print("PLASTIC alert")
|
|
|
|
if( self.rubbish[GLASS] > self.max_glass ):
|
2019-03-19 18:34:10 +01:00
|
|
|
self.image = pygame.image.load("images/house_glass.png")
|
2019-03-19 18:10:04 +01:00
|
|
|
print("GLASS alert")
|
|
|
|
if( self.rubbish[METAL] > self.max_metal ):
|
2019-03-19 18:34:10 +01:00
|
|
|
self.image = pygame.image.load("images/house_metal.png")
|
2019-03-19 18:10:04 +01:00
|
|
|
print("METAL alert")
|
|
|
|
|
|
|
|
def check_rubbish_status(self):
|
|
|
|
print( "plastic: " + str(self.rubbish[PLASTIC]) + " glass: " + str(self.rubbish[GLASS]) + " metal: " + str(self.rubbish[METAL]) )
|
|
|
|
|