def __init__(self, x, y, diffuculty, app): self.app = app self.sprite = pygame.image.load(resource_path("data/sprites/player.png")).convert_alpha() self.sprite2 = pygame.image.load(resource_path("data/sprites/player2.png")).convert_alpha() self.x = x self.y = y self.diffuculty = diffuculty self.x_vel = 0 self.y_vel = 0 self.angle = 0 self._i = False self.safe = False self.reset_color() self.sh1 = fill_with_color(self.sprite, (10, 10, 10), 200) self.sh2 = fill_with_color(self.sprite2, (10, 10, 10), 200)
def reset(self): #self.color = random.choice(Safehouse.colors) self.color = [0, 0, 0] n = random.randint(1, self.diffuculty) # needed to collect vs = Edible.colors.values() vs.remove(Edible.colors['blacky']) for i in xrange(0, n): c = random.choice(vs) for j in xrange(0, 3): v = self.color[j] + c[j] self.color[j] = max(0, min(255, v)) self.color = tuple(self.color) # fill sprite wiht a color self.sprite = fill_with_color(self.orig_sprite, self.color, 0)
def _recolor(self): fill_color = self.color if any(self.color) > 0 else (50, 50, 50) self.col_sprite1 = fill_with_color(self.sprite, fill_color, 0) self.col_sprite2 = fill_with_color(self.sprite2, fill_color, 0)