Question: Modify the Spaceship Control example so the ship keeps moving when the key is released. Do this by creating a float variable for x velocity
Modify the Spaceship Control example so the ship keeps moving when the key is released. Do this by creating a float variable for x velocity and one for y velocity. When a movement key is pressed, add or subtract from the corresponding velocity. Here is an example of the code when the move right key is pressed:
After the velocities are determined, use them to change the x and y position of the ship like this:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
