Rocket Landing Simulator

Gate Check #3 - Player Controls
Go Back to the Assignment Description

Part 1 (Overview) - Part 2 (Problem Description) - Part 3 (Rocket Controls) - Part 4 (Collision Check) - Part 5 (Metric Tracking) - Part 6 (Crash/Landing Detection)

Let's Control the Rocket!

The first thing we are going to do is add player controls to the rocket.

In the previous gate check, we created some variables that kept track of the amount we wanted to thrust in the up, left, and right directions. Do you remember how we modified these variables in update_rocket() in order to simulate the rocket Boosting off from the ground? We are going to do the same thing, except THIS TIME, we will modify the thruster variables when the user presses the arrow keys.

So . . . WHERE are we going to add this logic?

Go to the function you picked above. In this function, we need to modify the thruster variables depending upon which key(s) the player is pressing. From the requirements document, however, we know that there are restrictions on when the player can control the rocket. When can the rocket actually be controlled? Here is a participation activity to help you remember.

Now that we understand the task, let's implement this function!

def ():
    global 
    
    1.  Set thrust up, thrust right, and thrust left amounts to 0.0
    2.  If the rocket is NOT in the Boost Phase:
        2a.  If the player is holding down the left key, set the left thruster to amount to some small value (<0.5)
        2b.  If the player is holding down the right key, set the right thruster to amount to some small value (<0.5)
        2c.  If the player is holding down the up key, set the up thruster amount to some small value (<0.5) 

Testing

Once you have finished writing the drawing code, press play. You should be able to pilot the rocket using the arrow keys. If the arrow keys do not seem to work, check to make sure that your update_rocket() function has code to turn off the boosting variable once your rocket is over the while.

Play around with it a little bit and adjust the thruster values until the rocket flies like you would expect. When you are done, move to the next page.

Proceed to the next section.