Code skill Making the Game Scroll

This piece of code will make the tile scroll across the screen, so that it looks like the player is moving forwards. You will need to add speed and distanceTravelled properties to the World object, and then create a moveFloor function. In this function, you will add a loop to move the tile from the right to the left of the screen. By adding a tick function to the world object, you can call the moveFloor function every time the game ticks, which will make the floor move.

See the Pen GB2 M4 by Walker Books UK (@walkerbooks) on CodePen.