I’m sure you’ve played a few 2D side-scrollers. I’m sure some of those implemented parallax scrolling as well. If you don’t already know, parallax can be described as follows:
Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight, and is measured by the angle or semi-angle of inclination between those two lines. As the viewpoint moves side to side, the objects in the distance appear to move slower than the objects close to the camera.
One great example of this is standing in a forest, looking out and seeing many tree trunks. If you focus on one tree as you side-step in one direction while looking forward, you’ll see trees farther away are moving slower and trees closer are moving faster in respect to the one you chose to focus on. Making sense? Good! Anyway, I wanted to show a quick clip of what our parallax looked like.
Neat, huh? The process behind this is actually remarkably easy. Each “layer” of art gets its own parallax factor. This is just a multiplier that will be applied to the speed of the camera moving. If the parallax factor is less than 1 but greater than 0, the layer will move slower than the camera (such as the ocean at 0.8). If the factor is negative, they will move faster than the camera (such as the light posts at -.1). The pavement, pillars, and the car are all on the same layer as the player, so they move at normal speed (essentially 1.0).
Also, giving a shout-out to GifCam which was used to make this gif. Super easy and free (donations accepted!). Pretty much as good as the Snipping Tool for Windows. Will definitely be using in the future for posts here.