Skip main navigation

Moving the sprite

Scratch includes several blocks that allow you to move a sprite. Watch Vasu explain how you can move a sprite forwards, and turn it.

To get you started using the Scratch blocks, you will learn how to move and turn the Cat sprite. To do this, you will use an Event block to start a set of instructions and add blocks from the Motion category.

Event and Motion blocks

To start your program, you are going to use the when green flag clicked block from the Events category on the Blocks menu on the left.

The `when green flag clicked` block. This is a yellow block similar in shape to a rectangle with a rounded top and a bump at the bottom to snap into other blocks below itself.

When you click the green flag above the top left-hand corner of the Stage, Scratch will run the block connected to the bottom of the when green flag clicked block.

A screenshot of Scratch showing the green flag highlighted just above the top left-hand corner of the stage.

Each block will then run in the order of the sequence they are in, one after another.

You are also going to use the move () steps block from the Motion category.

The move (10) steps block is blue. It has a notch at the top and a bump at the bottom to snap into other blocks above and below itself.

The move () steps block will move the sprite in the direction the sprite is facing. The value in the block determines how far it moves. In the example above, the number of steps is set at 10. You can change this to any whole number to increase or decrease the length of the move.

Pixels and step length

To understand what distance your sprite will move on the Stage, you need to understand that your screen is made up of a grid of pixels (short for picture element). A pixel is one of the small squares that make up an image on your screen. Pixels vary slightly in size depending on the screen, but typically one pixel-length is less than 0.5mm.

One step is equal to moving along by the length of one pixel. The default of the move () steps block is 10 steps which is 10 pixel-lengths on your screen.

Turn blocks

The Turn blocks change the direction that the sprite is pointing. Scratch measures this in degrees (which split a full rotation up into 360 degrees), clockwise from vertically upwards (12 o’clock). Most sprites start with a direction value of 90, meaning that they are pointing horizontally to the right.

An animation showing a cat rotating around into several positions, with an arrow pointing in the direction it is pointing in each time. At the bottom there is a text label saying "Direction Value =" and the current direction value for the cat. This starts at 0 when the cat is facing upwards, and changes to 90 when the cat is facing to the right. When the cat is facing mostly downwards and slightly to the right the direction value is 150, and it is 170 when the cat is facing directly downwards. As the cat rotates clockwise to other positions, the number increases so it is 220 when the cat is pointing down and slightly to the left, 270 when it is pointing left, 320 when it is pointing slightly up and to the left, and 360 when it is again pointing vertically upwards.

You can use the turn right () degrees block shown below to change the direction value of the sprite the specified amount of degrees clockwise.

The turn right () degrees block is blue, the word "turn" is inside of the block, aligned to the left, followed by a circular arrow pointing clockwise. This is followed by a white area with the number "15" inside it, followed by the word "degrees". It has a notch at the top and a bump at the bottom to snap into other blocks above and below itself.

The default value for the turn block is 15. This will rotate your sprite 15 degrees in a clockwise direction as shown by the arrow on the block. You can change this value to any other angle you would like the sprite to rotate by.

Animated GIF showing someone using a `when green flag clicked` block connected to a `turn right () degrees` block. A Cat sprite is initially pointing to the right. The green flag is clicked and the cat rotates 15 degrees clockwise. Then the value in the `turn right () degrees` block is changed to another value and the green flag clicked again. This repeats several times to show how larger numbers cause more rotation.

The turn left () degrees block carries out a similar instruction to the turn right () block, except it will rotate your sprite in an anticlockwise direction.

The turn left (90) degrees block is blue, the word "turn" is inside of the block aligned to the left, followed by a circular arrow pointing anticlockwise. This is followed by a white area with the number "90" inside it, followed by the word "degrees". It has a notch at the top and a bump at the bottom to snap into other blocks above and below itself.

Your first program!

You are now going to create your first program in Scratch! Following these instructions, being careful that you do this exactly:

  1. Drag the when green flag clicked block onto the code area from the Events category of the Blocks menu.
  2. Drag the move () steps block from the Motion category of the blocks menu and snap it to the when green flag clicked block.
  3. Drag the turn right () degree block to the Code area and snap it to the bottom of the move () steps block.
  4. Click on the green flag on the Scratch user interface.

You should see the Cat sprite moving and rotating each time you click on the green flag.

  1. Increase the the number in the move () steps block. This will make the sprite move a larger distance in the direction it is facing when you click the green flag.
  2. Click the green flag again to see how the change you made affects the movement of the sprite.
  3. If you are using the installed version of Scratch, click on File and Save to your computer. Type a suitable file name and click Save. If you are using the online version of Scratch, make sure that you are signed in and change the project name by clicking on the current name (usually “Untitled”) at the top.

The Stage edge

As you move the sprite, it’s possible to have a situation where you would expect that the move that you have programmed would lead to the sprite moving off the Stage. Scratch will stop the whole of the sprite from leaving the Stage and will leave a small part visible.

A screenshot of Scratch, with a red arrow pointing towards a small section of the Scratch Cat sprite, which is just visible on the right edge of the Stage.

Task

Use the blocks in this step to move your sprite to each corner of the Stage.

  • What top tips would you give to other learners who are creating their first program in Scratch?

Share your thoughts in the comments below.

This article is from the free online

Introduction to Programming with Scratch

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education