This tutorial will show you how to make a Sprite jump in Scratch. At the end of this tutorial the sprite will move forwards, backwards, downwards and jump! Great if you want to build a Platformer!
Use the right, left, and down arrows to move the sprite, and space bar to make it jump!
Setting Up The Sprite’s Costumes
Before we can make a sprite jump in scratch, we’ll need to set up the sprite to have 2 costumes. One facing the right direction and one to face the left. In the Costume tab, first right click costume1 and select ‘duplicate’.

You can delete the other default costume, since we won’t need it.
Now go to the duplicate costume and click ‘flip horizontally’.

You should now have one sprite facing to the right, and the other facing the left. Be sure to pay attention to each of your sprite’s file names as we’ll be using these in the code.
Setting Up The Start Position
To make a sprite jump in scratch, we’ll reset our sprite to a starting position when the Green flag is clicked. So in our ‘Events’ tab, let’s grab the “when green flag clicked” block and drag it onto our board. Next in our ‘Motion’ tab, let’s grab a ‘go to X go to Y’ block and place that under our green flag block:

As you can see in the above image, I’m setting the X to -176 and the Y to -78 as my starting position.
Creating Variables In Scratch
Let’s create 2 new variables and call them xAxis and yAxis. This will give us complete control of our Sprite’s locations. Go to the ‘Variables’ tab and select Make a Variable then enter xAxis. Next do the same thing but for your second variable name it yAxis.

In our first code block, set the xAxis and yAxis variables to the same values in your ‘go to x/y’ block like so:

Make The Sprite Move With Right And Left Arrows
Start by selecting the “when space key pressed” block but change the ‘space’ to ‘right arrow’ as shown below. This will make the Sprite move to the right when the right arrow is pressed:

Add a set variable block under this block and set the xAxis to xAxis + 12. You can grab the addition green block from the Operators tab, and the xAxis from the Variables tab. The code should look like this below:

Now we need to move the Sprite to make it look like it’s moving to the right. So, we’ll take a go to x/y block from the Motion tab and set X to the xAxis variable and Y to the yAxis variable. Finally we’ll want to make sure the costume is set to costume1 (or the right facing costume).

Enjoying this tutorial? Don’t miss the “Make a Sprite Walk in Scratch tutorial too!”
Make The Sprite Move Left
To make the sprite move to the left, let’s go ahead and duplicate this code and just change 3 things. Right click the block by clicking on the ‘when right arrow key pressed’ block and select ‘duplicate’. Then:
- Change the right arrow to left arrow
- Remove the addition Operator and use a subtraction Operator so the set xAxis block is setting it to xAxis – 12
- Switch costume to costume3 (or whichever costume is facing left).
Your code should now look like this:

Make The Sprite Move With Down Arrow
Let’s copy this code once again by right clicking on the ‘when right arrow key pressed’. After duplicating the code, change the following:
- Change right arrow to down arrow
- Change set xAxis to set yAxis
- Change the Operator to subtraction and make the difference 80 instead of 12.
- Remove the switch costume block.
This code will make the Sprite move downwards with the down arrow
Your code should now look like this:

Make The Sprite Jump
Finally let’s make a sprite jump in Scratch! To start we will grab a “When space key pressed” block and add first the go to X/Y block set to xAxis and yAxis. Next we’ll set the yAxis to yAxis + 80 using the addition Operator block. We need to again add a go to X/Y block set to xAxis and yAxis. Your code should look like this below:

We don’t want our Sprite to hang out in mid air. (We want them to jump!) Let’s bring them back down to earth! In the Control section grab a “wait 1 second” block and change the 1 to 0.25. Next set the yAxis to yAxis – 80, then add a go to X/Y block set again to the xAxis and yAxis variables like this shown below:

We want to move our Sprite back to the beginning when they hit the edge of the screen. So let’s add and If block from the Control tab. Then grab from the Sensing tab, a “touching mouse-pointer” block but change it to ‘touching edge.’

Then all we have to do is copy the first code blocks we made in this tutorial. Now, place them inside the ‘if ‘block like this shown below:

The complete Jump on Spacebar code will look like this below:

See the code
Please check out the project on Scratch here and feel free to leave a comment, remix or copy the code as you need!