SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

6.03 Controlling the boat

The player will control the boat sprite with the mouse.

Add code to the boat sprite so that it starts in the bottom left-hand corner pointing up and then follows the mouse pointer.

boat-sprite

Test your code by clicking the green flag and moving the mouse. Does the boat sprite move towards the mouse pointer?

screenshot

What happens when the boat reaches the mouse pointer? Try it out to see what the problem is.

To stop this from happening, you need to add an if block to your code, so that the boat sprite only moves if it is more than 5 pixels away from the mouse pointer.

Test your code again to check whether the problem is now fixed.

×
×

Cart