Lesson 42: Repeating the Background
1. Download the project files and view index.html in a web browser. Take a look at the image files that will be used in the game..
Open index.html in a browser. Use the arrow keys to move the player ship left and right.
Be sure to go through all the code carefully so you have a clear understanding before you move on.
Illusion of movement
Often times you will want to move the background instead of the player character to give an illusion of movement. In this game, you want the player to feel as though they are always moving upward while the ship never actually moves up. You do this by having a background that continuously moves downward. You will use two backgrounds to ensure the background image always covers the gameScreen.
2. Add bg1 and bg2 as global variables and BG_SPEED as a global constant that will determine the speed at which the background moves.
At this point, the background should appear but not move.
4. Now just add the code into the gameloop() function to make the background continuously move.
That's it... the illusion of moving forward by continuosly moving the background is complete.