Movement: Arrow Keys
Click on the sprite you want to control with the arrow keys!
> Option 1: Simple
In events, drag the [when (space) key pressed]
block into your workspace and choose (up arrow).
Now we need to tell the sprite what it needs
to do when the up arrow key is pressed.
Go to motion and choose [point in direction (90)].
Click the small black arrow and choose ((0) up).
"0" is the same as up here because
this is how Scratch marks direction:
Now, if you run the game (by clicking the Green Flag!) and press the up arrow key, your
character points up but doesn't move. That's because we didn't tell it to move yet!
So now we can choose the
[move (10) steps] block. Test your game again (green flag!) and see your berryBro move up 10 steps! Adjust the number
to what you want it. I want 5.
Now, repeat this process for the other 3 directions, and your berryBro will have freedom
at last.
Note: to make your berryBro stop flipping upside down when it moves left, click on the blue "i" on your
sprite and then click on the left-right arrows outlined in this screencap.
> Option 2: Complex but Smoother
This option makes movement smoother but can be harder to understand for beginners.
Select the [when green flag clicked] block and put a blank [repeat until] under it.
A [repeat until] with nothing
in it acts exactly like a [forever] block!
Add an [if] and then go to the sensing category and find [key (space) pressed]. Change
it to (up arrow) and put it inside the [if].
Now we need to tell the sprite what it needs
to do when the up arrow key is pressed.
Go to motion and choose [point in direction (90)].
Click the small black arrow and choose ((0) up).
"0" is the same as up here because
this is how Scratch marks direction:
Now, if you run the game (by clicking the Green Flag!) and press the up arrow key, your
character points up but doesn't move. That's because we didn't tell it to move yet!
So now we can choose the
[move (10) steps] block. Test your game again (green flag!) and see your berryBro move up 10 steps! Adjust the number
to what you want it. I want 5.
Now, repeat this process for the other 3 directions, and your berryBro will have freedom
at last.
Note: to make your berryBro stop flipping upside down when it moves left, click on the blue "i" on your
sprite and then click on the left-right arrows outlined in this screencap.