Skip to content Skip to sidebar Skip to footer

Pygame Player Sprite Not Appearing

I've been working on this project for school computing class, and can't make the player sprite appear, can anybody help? When I run the main game loop, everything appears correctly

Solution 1:

In the __init__ method of your Player you create a rect but don't set its coordinates, so it's positioned at the default coordinates (0, 0). Then your collision detection code seems to push it above the level and you can't enter it again.

Set the coordinates of the rect to a point inside your level, e.g.:

self.rect = self.image.get_rect(topleft=(400, 300))
# Orself.rect.x = 400self.rect.y = 300# Orself.rect.topleft = (400, 300)

You could also pass the position to the __init__ method and then assign it to the rect, or set it when the level gets changed.

Post a Comment for "Pygame Player Sprite Not Appearing"