1

I have a selection of images that I will build a backdrop to a game from (it's a TD game but each level will be built from walls, walkways etc). I'm trying to work out how to dynamically build a single image to use as a background rather than having 100+ sprites for a background.

Teifion
  • 108,121
  • 75
  • 161
  • 195

2 Answers2

3

you will have to make pygame.surface with your images.

images = []
for image_name in image_names:
    images.append(pygame.image.load(image_name))

background = pygame.display.get_surface()
for image in images:
    back.blit(image, image_position) # how you compute the image position is your stuff ;)

pygame.display.update()
Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
1

You can always use PIL

See this post for details about how to combine images. You can basically "paste" one image into another image. Make one big blank image for your background, and then paste all the sprites into the background image.

Community
  • 1
  • 1
Brian O'Dell
  • 3,029
  • 1
  • 20
  • 23
  • BTW, you could use the composite image directly from memory rather than saving it out to a file: http://mail.python.org/pipermail/image-sig/2005-May/003315.html (but if pygame has something built-in, I'd definitely use that instead) – Mu Mind May 04 '11 at 16:09