I dont know why but my character is in the display but it cant move it is in a sprite group and it is updated all the time
class player(pygame.sprite.Sprite):
You have to continuously change the position of the ".rect" attribute in the "update" method by "speedy":
self.rect.y += self.speedy
Ensure that pygame.sprite.Group.update is invoked in every frame and change the position after evaluating the speed:
class player(pygame.sprite.Sprite):
# [...]
def update(self):
self.speedy = 0
keystate = pygame.key.get_pressed()
if keystate[pygame.K_UP]:
self.speedy = 8
if keystate[pygame.K_DOWN]:
self.speedy = -8
self.rect.y += self.speedy
if self.rect.bottom >= height:
self.rect.top = 0
if self.rect.top <= 0:
self.rect.bottom = height