コード例 #1
0
 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
コード例 #2
0
 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))
コード例 #3
0
 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))
コード例 #4
0
 def __init__(self, x, y, size):
     self.rect = pygame.Rect(x, y, size, size)
コード例 #5
0
 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
コード例 #6
0
 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