2D parallax...

Started by
4 comments, last by JohnHurt 16 years, 1 month ago
Quick q : Any ideas on how to incorporate parallax scrolling? The question is now so much *how* but *where*? Right now I am trying to add it into the rendering code, but it doesn't seem to fit very well. Right now , each tile has a set of attributes associated with it ( type , layer etc ) to distinguish the seperate levels. The only problem where to set the different scrolling rates... ahayweh
Advertisement
This is not a scroll rate issue, it's a scale issue. Change the scale of the background layers in the renderer after you've applied the translation, and the background tiles will be smaller and move around more slowly without any additional effort on your part.
Hmmm... I will try that. I should mention , I am using a 2D bliting library ( Allegro ) and making a retro 2D side scroller ala :



In my 2D engine (which is a while ago now), I had a scene manager which kept tiles and objects in seperate layers. These layers could be moved, updated and rendered seperately. To set the scroll speed of each layer you just set a "scroll factor" for it, which is basically just a number you multiply the current camera position by. So a layer with a factor of 1 will move at normal speed, 0.5 will move half as fast, 0 will be stationary etc. You could also have layers in front move faster, and also get layers to move the opposite way if you want to. With a bit of extra work you could also have layers auto-scroll, that way you can simulate clouds moving past in the background.
Ahhh.. A layering system. That makes very good sense. Then I could pass a pointer to the system to the renderer... Thanks for the idea. I may have to dismantle some elements to get it to work though , but the approach is very sensible.

thx
Rather than passing in the layer system to the renderer, I would do it the other way round. Renderers shouldn't really need to know about high level scenegraph details, they just draw stuff ;) Think what would happen if you wanted to re-use your renderer for another project that didn't have the same type of scene management.

This topic is closed to new replies.

Advertisement