Rocket Landing Simulator

Gate Check #2 - Basic Animation
Go Back to the Assignment Description

Part 1 (Overview) - Part 2 (Boat Animation) - Part 3 (Rocket Animation) - Part 4 (Thrusters)

Let's Move the Boat!

Let's do some animation! Specifically, let's write some code to make the boat move from the left to the right.

As you (undoubedtly) remember from class, moving an object requires that we continuously update the boat's x and y coordinates. Fortunately, the boat in our game is only moving in the horizontal direction. Therefore, we only need to modify x!

Before we get started, we need to remember what we did during the previous Gate Check. Here's a question to get you started!

Next, we need to think about which function(s) we are going to need to modify. Yeah, there's another question for that . . .

Now, we are finally ready to update our boat. Go to the update_boat() function, and write the code that will change the boat's x coordinate by its velocity every frame. Here is a basic logic design just in case you need it:

def update_boat():
    global 
    
    1.  Boat's x coordinate = Boat's x coordinate + Boat's velocity

If you press play in Thonny, you SHOULD see the boat move. You may need to adjust the random velocity you set in initialize_boat() if your boat is going too fast. Remember, this is a landing barge, not a jet ski. The velocity should be initialized to a very small value so that it appears to be slightly drifting.

If you strictly followed the above instructions, you are probably noticing that the boat is doing something weird. Specifically . . .

Testing

Once you have finished writing the drawing code, press play. You should see something similar to the following.

If you see the above images, you have completed this portion of the gate check.

Proceed to the next section.