Rocket Landing Simulator

Gate Check #1 - Initial Functionality
Go Back to the Assignment Description

Part 1 (Overview) - Part 2 (Getting Started) - Part 3 (Initializing the Sim) - Part 4 (Terrain) - Part 5 (Rocket) - Part 5 (Boat)

Initializing the Landing Boat

Finally, we are going to initialize the landing boat (in this assignment, we may accidentally refer to this as many things, such as "landing barge", "landing boat", "boat", "landing pad"; we apologize in advance for the confusion)

Again, the process is exactly the same as before. We are going to:

Step 1: Define Our variables

The landing boat is remarkably similar to the rocket in that it needs variables to keep track of its:

However, there is one key difference between the barge and the rocket that bears additional consideration. Do you know what it is?

Step 2: Initialize the Variables

Same as before, we need to actually assign values to our newly created variables. Go to the initialize_boat function and delete the print statement. Then write code to assign them values, using the logic design below as a guide:

# This is a global variable
def initialize_boat(generate_new_scenario):
    global 
    
    1.  If generate_new_scenario is True:
        1a.  Set starting x location to a random value ON THE WATER
        1b.  Set starting y location to be on top of the water
        1c.  Set starting x velocity to a (small) positive or negative value
    
    2.  Set x location to your starting x location
    3.  Set y location to your starting y location
    4.  Set x velocity to your starting x velocity

Note: When defining your x and y coordinates, you need to decide what the coordinate represents.

Step 3: Draw the Boat

The final step is to actually draw the landing boat. If you have been following all of the instructions to date, your draw_objects function should already call draw_boat. Consequently, all you have to do is go into draw_boat and write your code.

# This is a global variable
def draw_boat():
    1.  Draw the landing boat, using either pythonGraph.draw_image, or the other drawing functions.

There are many strategies that you can use to draw your boat. For example, you can use pythonGraph's draw_image function to simply draw a picture of the boat on the screen. This would let you draw the rocket using a paint program, and import it into your program. The sample code that we provide you gives you a simple boat image that you can use (but we bet you can come up with something even better!).

Alternatively, you COULD use pythonGraph's drawing functions and create a boat using circles, squares, etc. This approach is more difficult, but allows you to precisely control every pixel on the boat (you can even do some cool animations, like running lights, etc).

Regardless of which approach you pick, make sure make sure that your drawing code uses the (x, y) coordinate and the height/width variables you defined above. Otherwise, your boat will not move when we animate it.

Testing

When you have finished, press play. You should see something similar to the following:

If you see the above image, you have completed this gate check.

Proceed to the next section.