SCRATCH TUTORIAL SPACE SHUTTLE MISSION STS-2020
Lesson 5 Create Scripts for Shuttle Controls
- Description.
Use the arrow keys to move the Shuttle from side to side, and up and down.
If you haven't already, Launch the Scratch program from your desktop. - Let's get started!!!
- We will be using the freedom background. Click on the Stage icon, Select the freedombg.
- Script to move the Shuttle to the left.

Grab this block


Click on the arrow and then click on left arrow to select the left arrow key to move the Shuttle.
Click on

Grab this block


The x coordinate is side to side, horizontal to move the shuttle we have to subtract.
The Shuttle's starting coordinates are x:181 y:-131. As long as the left arrow key is pressed we subtract -1 from the x coordinate and the Shuttle moves to the left.
Test it
TIP: With this control block you do not have to doubleclick it to test. It is always on waiting for you to press the key.
Press the left arrow key to test.

Notice, when you reach the edge of the stage, part of the Shuttle goes pass the edge.
Let's tell it what to do when it touches the edge.
Grab this block


Now when the shuttle touches the edge it will bounce.
Test it

To make the Shuttle move faster, change the number. Try -5
- Script to move the Shuttle to the right.

We don't have to drag the blocks, since our blocks will be the same we can copy the stack.
Place your mouse pointer over the top block in the stack and right click. then click duplicate.
Move the new stack and click to drop it.

On the contol block select right arrow.
To move to the left, we had to subtract from the x coordinate.
To move to the right we have to add to the x coordinate.
change x by 1.
Test it

- Script to move the Shuttle up.
To move it up we have to add to the y coordinate
Since only 1 block changes, we can duplicate a stack.
Move the mouse pointer over the top block in the stack and duplicate

Grab and drag this block

Grab this block from the Script Block area

Drag and snap the blocks back together.

On this block

Test it and

- Script to move the Shuttle down.
To move it down we have to subtract form the y coordinate
Move the mouse pointer over the top block in the up stack and duplicate

On this block

Test it and

- Clean up the Script Area.

If your Script Area gets messy, block stacks not lined up.
Move the mouse pointer to a clear place on the Script area. Right click then click Clean up

- Update Notes.

I put this in mine:
Shuttle Controls: Use the arrow keys to move the Shuttle.

- Finished Lesson 5
- Start Lesson 6 Create Scripts Create Script to Rotate the Shuttle Sprite