def unlock(self): if not self.locked: return if self.rotation % 180 == 0: self.image = self.parent_surface.subsurface(pygame.Rect(0, 0, self.image.get_width(), self.image.get_height())) else: self.image = self.parent_surface.subsurface(pygame.Rect(0, 0, self.image.get_height(), self.image.get_width())) self.image = pygame.transform.rotate(self.image, self.rotation) self.locked = False
def set_place(self, level): # Will search for tags and make a big trigger box try: for i in range(len(level)): for j in range(len(level[i])): if self.placeWhere in level[i][j]: if self.rect.size == (0, 0): self.rect = pygame.Rect(j * drawSize, i * drawSize, drawSize, drawSize) else: self.rect = self.rect.union(pygame.Rect(j * drawSize, i * drawSize, drawSize, drawSize)) except AttributeError: print("The placeWhere attribute is not set in " + str(self))
def __init__(self, rect, surface, scale=False): super(SimpleRectSprite, self).__init__() self.rect = pygame.Rect(rect) self.image = surface rect.topleft = (0, 0) if not scale: self.image = surface.subsurface(rect) else: self.image = pygame.transform.scale(surface, (rect.w, rect.h))
def __init__(self, x, y, size): self.rect = pygame.Rect(x, y, size, size)
def open(self): self.surface = pygame.transform.flip(self.surface, True, False) super(Chest, self).__init__(pygame.Rect(self.topleft[0], self.topleft[1], drawSize, drawSize), self.surface, True) self.opened = True
def __init__(self, top_left_point, surface, opened=False): self.surface = surface surface = surface.subsurface(pygame.Rect(0, 0, surface.get_width() / 2, surface.get_height() / 2)) super(Chest, self).__init__(pygame.Rect(top_left_point[0], top_left_point[1], drawSize, drawSize), self.surface, True) self.opened = opened self.topleft = top_left_point