I am doing a little game, I am new at programming so i wanna start somehow so i have got a game and i want to add animation when you are walking. But i am not able to use more images it is showing me this error. and if you will be open to give me advise for using animation it would be great. I have this (in the important section):
JavaScript
x
25
25
1
def __init__(self):
2
pygame.sprite.Sprite.__init__(self)
3
self.images = []
4
for i in range(1, 5):
5
mich = pygame.image.load(os.path.join('images', r'C:/users/filip/documents/rozsireni/Jumpi'
6
r'ng 6.png')).convert()
7
mich2 = pygame.image.load(os.path.join('images', r'C:/users/filip/documents/rozsireni/Jumpi'
8
r'ng 7.png')).convert()
9
mich = pygame.transform.scale(mich, (100, 100))
10
mich2 = pygame.transform.scale(mich2, (100, 100))
11
mich.convert_alpha()
12
mich.set_colorkey(ALPHA)
13
mich2.convert_alpha()
14
mich2.set_colorkey(ALPHA)
15
self.images.append(mich, mich2)
16
self.image = self.images[0]
17
self.rect = self.image.get_rect()
18
19
20
player = Player()
21
player.rect.x = 300
22
player.rect.y = 300
23
player_list = pygame.sprite.Group()
24
player_list.add(player)
25
Advertisement
Answer
The issue is with list.append
JavaScript
1
2
1
self.images.append(mich, mich2)
2
You can only append one element at a time, use list.extend([...])
instead if you want to append several elements.