Coding Ireland STEM Report 2024
Mathematics Scratch Game
Expert
60 mins
335 points
What you need:
Computer/laptop

# Rocket Lander

The Space X Falcon 9 rocket is capable of landing back on earth on top of a moving ship at sea, in this project we try and recreate the landing and make it into a game.

Learning Goals Learning Outcomes Lesson Files

### 1 - The Space X Falcon 9

Unlike most rockets that get launched into space, which can never be used again can never be used, the Falcon 9 is capable of re-entering the atmosphere and landing vertically. This feat was achieved for the first time on flight 20 in December 2015.

As the flight number 20 suggests, there were many tests and attempts before flight number 20 that weren't successful! Don't worry though all these rockets are unmanned and are either piloted by computers and remotely from the mission control center.

### 2 - Open the starter project

Open this starter project in Scratch.

### 3 - Program gravity

When a rocket enters back into Earth's atmosphere, gravity will start to pull it downwards. We can simulate this in code by changing the Y position of the sprite.

Add the following code to the rocket sprite to make it:

• start at the top center.
• point upwards (be vertical).
• start falling.

``` when green flag clicked go to x (0) y (200) point in direction (0) forever change y by (-5) end ```

### 4 - Program booster

Now let's program the up arrow to make the rocket fires it's booster so we can slow it down.

Add the following code to the rocket sprite.

``` when green flag clicked forever if < key (up arrow v) pressed? > then move (8) steps end ```

When you try it out you'll see that you can slow down the rocket and even make it go back up again. This is because move 8 steps  is greater than change y by -5

### 5 - Paint the rocket thrust

To make it more realistic when we fire the rocket's booster, we will create a new costume for the rocket sprite with fire thrusting out of the bottom.

• Open the costume editor.
• Rename the costume to 'normal'.
• Duplicate the normal costume and rename it to 'thrust'.
• Convert it to a Vector image.
• Use the paint tools to draw fire coming out at the bottom of the rocket (in the 'thrust' costume).

To start off the game the rocket sprite should be showing the 'normal' costume so add switch costume to (normal) blocks underneath the when clicked block and also underneath the change y by -5  block.

``` when green flag clicked switch costume to (normal v)// add this block go to x (0) y (200) point in direction (0) forever change y by (-5) switch costume to (normal v)// add this block end ```

# Unlock the Full Learning Experience

Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our courses.