import pygame from sprites.cell import Cell, CELL_SIZE from config import PLAY_HEIGHT, PLAY_WIDTH class Garbage_collector(Cell): def __init__(self, x, y): GC_CAPACITY = 10 Cell.__init__(self, x, y) self.image = pygame.image.load("images/garbage_collector.png") self.move_options = { "up": lambda forbidden: ('y', self.y - 1) if (self.x, self.y - 1) not in forbidden and self.y - 1 >= 0 else ('y', self.y), "down": lambda forbidden: ('y', self.y + 1) if (self.x, self.y + 1) not in forbidden and self.y + 1 < PLAY_HEIGHT // CELL_SIZE else ('y', self.y), "left": lambda forbidden: ('x', self.x - 1) if (self.x - 1, self.y) not in forbidden and self.x - 1 >= 0 else ('x', self.x), "right": lambda forbidden: ('x', self.x + 1) if (self.x + 1, self.y) not in forbidden and self.x + 1 < PLAY_WIDTH // CELL_SIZE else ('x', self.x) } self.trash_space_taken = { "plastic": 0, "glass": 0, "metal": 0 } self.trash_collected = 0 def move(self, direction, forbidden): (destination, value) = self.move_options[direction](forbidden) if(destination is 'x'): self.x = value elif(destination is 'y'): self.y = value self.update() def get_collect_data(self): return self.trash_collected def get_space_data(self): return self.trash_space_taken