コード例 #1
0
screen = pygame.Surface((600, 400))

clock = pygame.time.Clock()
inGame = True

im = pygame.image.load('images\\brick.png')
im2 = pygame.image.load('images\\q1.png')

g = Group()

# Первый способ
s = Sprite()
s.image = im
s.rect = s.image.get_rect()
s.rect.topleft = 100, 150
s.add(g)


# Второй способ
class Obj(Sprite):
    def __init__(self, im, x, y):
        Sprite.__init__(self)
        self.image = im
        self.rect = self.image.get_rect()
        self.rect.topleft = x, y
        self.add(g)


class Im(Obj):
    def __init__(self, x, y):
        Obj.__init__(self, im, x, y)