This tutorial will show you how to make a Sprite walk in Scratch. At the end of this tutorial the sprite will walk forwards and have a scrolling background. It will end up looking like a Platformer!
Use the right arrow to make your sprite walk!
Making the Cat Sprite Walk
The Costumes
First up to make a Sprite walk in Scratch, we need to see what the default sprite’s costumes are. The cat already has 2 costumes which could work to make it look like it’s walking, go to the ‘Costumes’ tab to view them.
To make it look like our sprite is walking to the right of the screen, we’re going to use Costum1 and Costume2 in our code.

The Code
To make a Sprite walk in Scratch, next we need to code the sprite to appear to be walking. In the Code tab, start with a “Key Press Block”, the block by default says “when ‘space’ key pressed”. As you can see below, we’re changing the ‘space’ key press, to the ‘right arrow’ key press instead.

Next, we will set the costume to costume2, and switch back and forth. Let’s start by grabbing from the ‘Looks’ tab, the switch costume to costume2 block:

And we’ll place that in the ‘right arrow’ command to make the Sprite walk in Scratch.

After that, we want to wait half a second to switch costumes. (You can also try 0.25 for a faster moving sprite!) We’ll grab the ‘wait 1 seconds’ block, change the 1 to 0.5 and then add it under the ‘switch costume’ block.

We’ll repeat this code but switch to the costume1 block now.

Our code should now look like this below. (Does the Sprite look like it’s walking to you?):

Now go ahead and give it a shot, when you press the right arrow key, does your sprite look like it’s walking?
Enjoying this tutorial? You can learn how to make a Sprite Jump in this post too!
Making A Scrolling Background
To make a Sprite look like it’s walking with a scrolling background, we need to make 2 sprites. These 2 Sprites will behave as our backgrounds.
If you like to use video tutorials, check out the tutorial below:
Check out this helpful video from the Scratch Team on how to make a scrolling background. But, I’ll cover in this post how to make the background work with our walking sprite!
Designing A Background Sprite
Start by mousing or tabbing over the “Choose a Sprite” button and select “Paint”.

Next, use the square shape to make a blue rectangle. Make sure it goes all the way across the Scratch Live View

Do the same with a green square until it looks like this:

Next, create a grey circle, (this will be a stone!)

Click the ‘Reshape’ button. Then move the bottom dot of the circle up until it looks like a stone:

You can duplicate the stone by right clicking the stone. Then select ‘copy image’. Then hit (ctrl + V) on a PC or (Command + V) on a Mac!
Now we’re making the Sprite walk in Scratch more appealing:

Coding The Background Sprite
Back in the ‘code’ tab of our sprite, we’ll start with the ‘right arrow’ event again. Our first command will be to send our “background” sprite to the back layer!

Next up we want to set our background position so the X and Y are set to 0 like this shown below:

We’re going to use a ‘Repeat Until’ block from the ‘Controls’ tab. This will make our background move only when the right arrow key is pressed. We’re going to grab the ‘not’ block from the ‘Operators’ tab. Then, from the Sensing tab we’ll grab the ‘key space pressed’ block and set ‘space’ to ‘right arrow’. Our ‘repeat until’ block should now look like this:

Inside the ‘repeat until’ block, let’s tell our sprite to change X by -10. This will make the background sprite start to move to the left. That makes the background appear to move as we’d expect:

We’ll add some more code inside our ‘repeat until’ block. This will make our sprite move back to the beginning again . We’re going to say that whenever X is less than -523, have the coordinates go to X:523 and Y:0. Here’s the complete code for our first background sprite:

We now need to duplicate this sprite. Right click on the background sprite and select ‘duplicate’.

The second background sprite code will need to changed like this below. This will make your Sprite appear to walk in Scratch:

See and Remix the Code!
Please feel free to check out the code here. Have fun remixing it, or using whatever parts you’d like to use! Thanks so much for checking out this post. I hope it’s helped you out!