Infinite Scrolling background?

Hey,

Basically, I want to add a background layer that would scroll infinitly. You know, such as a “clouds” layer that would scroll across the background of my level slowly…but would never end.

I’m not so much looking for code on how to do this…just help on an algorithm that could do this.

As much as I could figure so far would be to use two identical pictures (both bigger than the display size) and as one is X pixels away from the edge of it being the edge of the screen, start drawing the second picture after it so it smoothly scrolls on…then repeat the process as it reaches the end of the second picture (but switching back to drawing the first).

Though for some reason I cant settle on that idea, maybe I’m just paranoid or whatever…but I figured I’d ask and see if anyone can comment on my plan? I havent had a chance to try coding it yet as this isnt my machine I am posting from :slight_smile:

Usually tiles are used. Since the background doesnt need that much variation (compared to the foreground) you can use rather big tiles there… like 128x128.

You can also do it with a tilable image that is at elast the size of the screen. You just “wrap” ity by doing two BLTs.