SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

2.02 Character movement

Character movement

Start by creating a character that can move left and right, and can climb up ladders.

Open the ‘Dodgeball’ Scratch starter project.

Online: open the starter project at dodgeball-on.

The project contains a backdrop with platforms:

dodgeball project background

Choose a new sprite as the character the player will control, and add it to your project. It’s best if you choose a sprite with multiple costumes, so that you can make it look as though it’s walking.

pick a sprite

Click on Choose a Sprite to open the Sprite Library:

The 'Choose a Sprite' icon highlighted.

You can search for a sprite, or browse for one by category. Click on a sprite to add it to your project.

The Sprite Library.

Add code blocks to your character sprite so that the player can use the arrow keys to move the character around. When the player presses the right arrow, the character should point right, move a few steps, and change to the next costume:

pico walking sprite

If your sprite doesn’t fit, adjust its size.

set sprite size so it fits

Test out your character by clicking the flag and then holding down the right arrow key. Does your character move to the right? Does your character look like it is walking?

screenshot

Add code blocks to the character sprite’s forever loop so that it walks left if the left arrow key is pressed.

Test your new code to make sure that it works. Does your character turn upside-down when walking to the left?

screenshot

If so, you can fix this by clicking on the direction of your character sprite, and then clicking on the left-right arrow.

screenshot

Or if you prefer, you can also fix the problem by adding this block to the start of your character’s script:

To climb a pink ladder, your character sprite should move a few steps upwards on the Stage whenever the up arrow is pressed and the character is touching the correct colour.

Add inside your character’s forever loop to change the character’s y (vertical) position if the up arrow is pressed and the character is touching the colour pink.

pico walking sprite

Test your code. Can you make the character climb the pink ladders and get to the end of the level?

screenshot
×
×

Cart