Print This Lesson

Lesson 4     Create Scripts (programs)

  • Create a Script. You can give instructions to a sprite, telling it to move or play music or react to other sprites. To tell a sprite what to do, you snap together graphic blocks into stacks, called scripts. When you double-click on a script, Scratch runs the blocks from the top of the script to the bottom.

    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.
To get to the Shuttle sprite interface, in the Sprite list, Click on Shuttle icon

  • Changing x: y: position and resizing a sprite.
About the Stage:
The Stage is 480 units wide and 360 units tall. It is divided into an x-y grid. The middle of the Stage has an x-coordinate of 0 and a y-coordinate of 0.

Look at the Shuttles, see how the x-y coordinates change for each one

The x coordinates go from side to side, horizontal.

The y coordinates go up and down, vertical.

Find the picture of the mouse pointer.
To find out x-y positions on the Stage, move the mouse around and look at the mouse x-y display just below the Stage, on the right.

This is the sprite info area.
Notice the x-y coordinates, this is the cuurent position of the sprite on the stage.
Grab the Shuttle and move it, see how the x-y coordinates change.

  • Let's Resize the Shuttle

Let's make the Shuttle the same size as the one in the background.

Mine is bigger so I have to click on the Shrink Sprite button, then move the pointer over my shuttle and click the mouse. Keep clicking the mouse until it is close to the same size. If you make it too small, click on the Grow Sprite button, to make it bigger.

Keep resizing until you get the Shuttle the size you like.


  • Let's make the Script to position the Shuttle sprite where we want it when the Game starts.
To get to the Shuttle sprite interface, in the Sprite list, Click on Shuttle icon

Click on the Scripts tab

We need to tell the Shuttle what to do when the game starts.

Click on the Controls button

Grab this block and drag it into the script area.
This control block controls what happens when the green flag is clicked to start the game.

Let's tell the Shuttle where we want it and in what direction to be in when the game starts.

In the stage area, Grab the Shuttle and drag it to the bottom right of the stage.

Look in the Shuttle sprite info area.

Notice that the Shuttle location is x:181 y:-131. Keep moving your Shuttle until it is at this location.
Notice the direction: 90 degrees (up).

To rotate,
Click and drag the Shuttle icon in the info area until direction: 0

This is the position we want the Shuttle when the game starts.

Click on the Motion button

Grab and drag these 2 blocks into the Script area and snap them together.

On the, point in direction motion block, set it to 0

This is our First Script.
Let's test it. On the stage, grab the shuttle move it, anywhere.
In the sprite info area click and drag the shuttle icon to rotate it, any direction except 0.

Now, double click the Control block
The shuttle should move back to the start position.

To change the x-y coordinates, click inside the circle and type in new numbers.

Try it change the coordinates and then doubleclick the Control block to test.