Python - Ejercicio de Pygame TypeError:

 
Vista:
sin imagen de perfil

Ejercicio de Pygame TypeError:

Publicado por Héctor (3 intervenciones) el 31/12/2021 18:22:13
Hola, estoy intentado añadir la animacion de movimiento en mi proyecto pero una vez hecho esto en la clase me sale el siguiente error:
self.count += 1
TypeError: unsupported operand type(s) for +=: 'pygame.Surface' and 'int'


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.count = 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)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder