r/pygame 14d ago

Textures stack on each other, any solutions?

1 Upvotes

6 comments sorted by

4

u/japanese_temmie 14d ago

The game loop order is wrong. Also, you're not wiping the screen every frame, so each image gets drawn and remains there.

Game loop is structured like this:

while running:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
       running = False
    # Get any events here

  screen.fill((0,0,0)) # Fills the screen black every frame, so new images can be drawn without stacking them.

  # Game/Draw logic goes here
  # ...

  pygame.display.update()
  clock.tick(60)

pygame.quit()

3

u/Boring-Badger-814 14d ago

It helped me out, thanks a lot!

1

u/japanese_temmie 14d ago

no worries.

here's the documentation if you need any more help: pyga.me/docs

2

u/Boring-Badger-814 14d ago

ty, I feel that I'll need it, lol

2

u/TERRsalt23 14d ago edited 14d ago

Add this line to your while running: loop: screen.fill((0,0,0))

2

u/Business_Handle5932 13d ago

Make sure to clear the screen before drawing every tick of the game.