General Instructions:
Click on the link to open the
Starter file,
it contains images and some code to help you get started.
Now, click on the fork icon .
Then at the bottom it will give the option to fork the project to save and modify .
Add the code inside the highlighted box in the examples.
Write a pair of push and pop function. This piece of code will consolidate the code inside it.
Place the translate function with the x, y and z variables inside the push() and pop() to move
the entire spaceship.
Place another push()and pop(), after the translate().
Here between push() and pop(),the code for the spaceship you have design will go.
Use forward slashes to comment for the movement of the spaceship code.
Add the conditional statement, if the up arrow key is pressed down .
Then decrement the y variable by some value to move up.
Make another conditional statement this time when the down arrow key is pressed down.
Then increment the y variable to move down.
Do the same for moving right and left in the x-axis. The x value decrements on left and
increments on the right hand side.
Do the same for moving near and far in the z-axis. The z value decrements , when going far and
increments , when moving near. Here, space key (32) and Enter key (13)is used for moving in z-axis.
Call the starry function in the draw(), to make the stars appear in the background.
Make the scrolling background by adding the following code in the conditional statements.
If spaceship is moving up then the background
should move the opposite way to give the scrolling effect.
If spaceship is moving down then the background
should move up to give the scrolling effect.
If spaceship is moving side to side then the background
should move in the oppsite direction to give the scrolling effect.
Happy Coding!!