Page 1 of 1
Having Trouble With 2 Independent Backgrounds
Posted: Sun Sep 29, 2013 11:19 am
by HJW012
In a game I am attempting to create, I plan on having a background that moves in a linear way directly in relation to the player's movement. Behind that, I plan on having a background that moves quite slowly in comparrison to the player's movement. This is to simulate a background that is a substantial distance away. I was just wondering how I should go about doing this. I have thought about having it move directly with the push of the movement buttons but that was not successful. Any ideas are welcome. Thank you.
Ps. If you are unsure of what I mean by this background, the game 'Guacamelee' is a perfect example.
Re: Having Trouble With 2 Independent Backgrounds
Posted: Sun Sep 29, 2013 11:40 am
by micha
This type of background scrolling is called parallax scrolling.
Usually you implement that by having a fixed ration of the two backgrounds scrolling speed, say 2.
So somewhere you store how far the background has moved (in pixels) for the second background, simply divide this distance by the above factor (2) and use this distance as displacement for the second background (the one farther away).
So if for example the front background moved 100 pixels, move the other one only 50 pixels.
[]
Posted: Sun Sep 29, 2013 12:40 pm
by bekey
-snip-