I need to make not repeating background for platformer. I can't find any description of implementation and I developed algorithm but I'm not sure that it's right.

I can't load one big texture per level, because many devices don't support textures more than 2048x2048 pixels and my levels require 4096 pixels at least on the one side. Therefore I have to cut big texture into smalls(512x512, 1024x1024), load them using separate thread and render. Picture shows it:

enter image description here

Green rectangle is screen(for example Nexus S with display 800x480)


  1. In case 2 layers I have to keep in memory 4 big textures.
  2. I have to constantly load and unload big textures.
  3. Additional thread.

If it's not problems then ok :) But it seems that I'm doing something wrong.

  • 2
    \$\begingroup\$ Canonically: rather than chopping up your texture into a 2x2 block of 1024^2 textures, chop it up into e.g. a 4x4 grid of 512^2 textures, or even an 8x8 grid of 256^2 textures, and keep a small 'buffer' around the player, preemptively loading the next textures in the direction the player is currently moving. \$\endgroup\$ – Steven Stadnicki Feb 19 '13 at 19:26
  • 1
    \$\begingroup\$ What is your question? \$\endgroup\$ – Trevor Powell Feb 19 '13 at 23:02

I think what you're looking for here is a classical example of tile-mapping which allows you to create levels and the like without consuming a LOT of resources. This is how Mario Bros was written along with other countless side-scrolling games are designed. You simply use a map editor such as Tiled (or a home-brew solution) to design your level from a chunked texture such as this:

enter image description here

(Thanks to OpenGameArt for the graphics!).

The background can be done in a similar fashion, just on a separate layer which scrolls slower (see: parallax) or just by ripping parts off the tile sheet. Say, those birds... you can place them in the sky randomly or clouds. However, if your level is to be the same every playthrough it's best to just build them on a separate parallax layer.

| improve this answer | |
  • \$\begingroup\$ Did you miss the part where he said "not repeating"? \$\endgroup\$ – Junuxx Feb 20 '13 at 17:17
  • \$\begingroup\$ @Junuxx No, I made it quite clear that you could design the background using tile-maps... that is not at all repeating. \$\endgroup\$ – Vaughan Hilts Feb 21 '13 at 3:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.