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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!