This is an old revision of the document!
An infinite runner involves a character moving along an infinitely long stage overcoming obstacles placed along the path. That's the foundation. Other additions can include an increasing speed, procedurally generated obstacles, etc.
A parallax background involves multiple layers scrolling along at different speeds to simulate depth. Layers farther back in the scene move slower than those closer to the camera.
Each layer needs at least a X Position and Speed variables. On each frame, the X Position is subtracted by the Speed, so that the layer moves at a constant rate. Once the layer moves off-screen, increment its' X Position by the width of the layer asset so it's back on-screen and the scrolling effect doesn't have any cuts. (For simplicity, each layer asset is the width of the screen size.)
Sometimes you want to include alternate variants of a layer asset for added visual flair. This'll require an array for however many slots you want within the layer (For this example, we'll go six with the last slot being the variant). We'll use a type variable to determine which asset variant to select (a boolean). When rendering the layer, it looks at the type to determine the texture variant to select.
Since the parallax background already gives the impression of horizontal speed, the player does not actually need to move across the X-axis of the screen. This value can remain fixed throughout all gameplay scenarios.
The player will be able to perform two actions while automatically running along: Sliding and Jumping with the A and B buttons respectively. These two actions are mutually exclusive.
Sliding is simple. When the B button is held, the player will slide along the ground indefinitely. In this state, the player is half as tall and can duck under obstacles. Jumping is more complicated.