Shanan
Shanan

Reputation: 33

How to blit a background without erasing other layers

I have 2 layers in Pygame right now: 1st: Background image that moves 2nd: the characters, items, lasers, etc. this layer is obviously in front of the 1st layer.

however, whenever i try to blit the 1st layer (background), it erases anything (particularly the lasers and any other items that appears only for a certain amount of time) that is on the 2nd layer. Is there a way so that even if the background blits, it doesnt erase all the contents of layer 2?

Upvotes: 0

Views: 310

Answers (1)

Serial
Serial

Reputation: 8045

in youre loop you need to do something like this

while True:
    screen.blit(background(0,0))
    screen.blit(item(100,100))
    #etc.

this way the loop while blit the background then blit the image then re-blit the background to refresh the images on top then re-blit the images on top

this way it will blit eachlayer over and over again refreshing on each iteration if the loop i could help more if you showed some of youre code

Upvotes: 1

Related Questions