![]() |
|
Parallax scrolling in 2D tile engine |
Jose Rubio
Member #1,159
April 2001
![]() |
Hi guys, I've been toying lately with a 2D tile engine which supports an arbitrary number of layers, defining one of them as the 'playing' layer. I have been thinking of the idea of adding parallax scrolling but I have lots of doubts about it, from the best way of implementing it (factor of movement with respect to the playing layer) to doubts like if it will be necessary to have subpixel precission to effectively do a smooth parallaxing... Any ideas on the matter? Did any of you implemented such an engine? Thanks for your advice! |
Audric
Member #907
January 2001
|
From my experience, you track the offset of the most important layer, it can be an integer, and then all other layers' offsets are computed as main_offset*A/B (with A and B in integers too: main_offset*1/2, main_offset*3/4, main_offset*6/5.). I think you can't do anything about smoothness if you can't get any precise data about physical refreshes - and on the PC nowadays, you don't. |
Jose Rubio
Member #1,159
April 2001
![]() |
I want to implement it with a simple frame buffer with double buffering at most. Maybe it would be a good idea to replicate in software what hardware like GameBoy Advance or Nintendo DS does to manage scrolling. |
Audric
Member #907
January 2001
|
Jose Rubio said: Maybe it would be a good idea to replicate in software what hardware like GameBoy Advance or Nintendo DS does to manage scrolling. Bad idea. Why would you emulate a system that has constraints of bitmap size, placement, clipping, etc. when you could instead use allegro's functions that have none of it ? |
Jose Rubio
Member #1,159
April 2001
![]() |
Well, I was thinking more of using the principles the hardware uses, not its limits. The one thing that currently bothers me is... let's say I have two layers of the same size. If I scroll one faster than the other, eventually I'll run out of tiles... how does people solve this? The background layer wraps around? I've also seen background layers being bigger than foreground... but I don't see any practical benefit from this, besides the fact that you will not run out of tiles when you reach the edge of the playing layer... |
Audric
Member #907
January 2001
|
Yes, wrapping is used very often. |
|