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:
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.
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:
If your sprite doesn’t fit, adjust its size.
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?
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?
If so, you can fix this by clicking on the direction of your character sprite, and then clicking on the left-right arrow.
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
.
Test your code. Can you make the character climb the pink ladders and get to the end of the level?