Back to all Refresher Lessons
Movement: Mouse
Click on the sprite you want to control with the mouse!

In events, 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!

Go to motion and select the [point towards (mouse-pointer)] block.
Press the green flag to test your code. Right now your berryBro should be spinning to face where your mouse cursor is!

But berryBro isn't moving! This is because we haven't told it to move yet, just point towards our mouse.
Now we can choose the [move (10) steps] block. Test your game again (green flag!) and see your berryBro chase your mouse. Adjust the number if he's going too fast. I want 2 steps.

To make your berryBro stop freaking out when it gets to your mouse, we have to tell it that it can only move if it's not already touching the mouse pointer.
Choose an [if] block from control and drag it around the movement code, inside of your [repeat until]. Then find a [not] block in operators and put it in the [if]. Finally, find the [touching (mouse-pointer)] block in sensing and put it inside the [not].
Now your berryBro will only move if it's not already touching the mouse pointer!

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.
Congratulations! Your berryBro is now controlled by your mouse!