Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hero sprite must be erased before updating display #1

Closed
umbe1987 opened this issue Dec 20, 2017 · 0 comments
Closed

Hero sprite must be erased before updating display #1

umbe1987 opened this issue Dec 20, 2017 · 0 comments

Comments

@umbe1987
Copy link
Owner

Before calling pygame.display.update(hero.rect), the hero.rect in the previous frame position should be filled with background, otherwise once it is moved, all its previous positions still get rendered in the next display.update call.
Basically, the solution is explained here:

  • Blit a piece of the background over the sprite’s current location, erasing it.
  • Append the sprite’s current location rectangle to a list called dirty_rects.
  • Move the sprite.
  • Draw the sprite at it’s new location.
  • Append the sprite’s new location to my dirty_rects list.
  • Call display.update(dirty_rects)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant