i have another issue, and this time with a IndexError that i cant solve, the error that jumps onto screen is:
self.image = self.image_list[self.count],
IndexError: list index out of range
rigto = [pygame.image.load("img/Iconos/guy1.png"), pygame.image.load("img/Iconos/guy2.png"), pygame.image.load("img/Iconos/guy3.png"), pygame.image.load("img/Iconos/guy4.png")]
class Player:
def __init__(self, x, y, image_list):
self.image_list = image_list
self.count = 0
self.image = self.image_list[self.count]
self.rect = self.image.get_rect(topleft = (x, y))
def update(self): # update se utiliza para la posicion del jugador y su movilidad
dx = 0
dy = 0
self.count += 1
frame = self.count // 10
if frame >= len(self.image_list):
self.count = 0
frame = 0
self.image = self.image_list[self.count]
key = pygame.key.get_pressed()
if key[pygame.K_a]:
dx -= 5
self.direction = -1
if key[pygame.K_d]:
dx += 5
self.direction = 1
if key[pygame.K_w]:
dy -= 5
if key[pygame.K_s]:
dy += 5
if key[pygame.K_z]:
pygame.mixer.music.play(-1, 0.0, 5000)
draw_text("Tienes " + str(money) + " monedas", font_score, (0, 0, 0), 800, 10)
# update player coordinates
self.rect.x += dx
self.rect.y += dy
def draw(self):
pantalla.blit(self.image, self.rect)
jugador1 = Player(500, 500, rigto)