Parallax scrolling


Parallax scrolling is an effect I always loved in games that I played back in the day.

Below is an example from sonic I found on google. The parallax effect has the background moving at different speed to give an impression of depth.


This is usually fairly easy to compute for 2d games. As the player's x changes in the level, scroll the background by some factor based on x.

The issue for "Modulus7" is there's no analogous value for x. The player is free to move x,y and rotate.

I initially tried to use rotation, i.e. scale the position against the background based on the player's angle.


However, the problem here is that angle doesn't scale nicely once you hit a full rotation. 360 snaps hard back to 0 

The solution was to instead give the background elements a distance to scroll through, and treat the rotation as a percentage from 0->360


If the blue rectangle is the camera, this allows the background objects to snap at known locations outside the field of view. 


the smaller moon catches up to the bigger moon successfully as the screen rotates

Leave a comment

Log in with itch.io to leave a comment.