Sprite Chase (Sprite interaction)
In this lab, you will program two sprites. One sprite will follow your mouse. The other sprite will chase the first.
When they meet, they will have a short conversation.

Let's get started!
-
Click here to load a starter project.
-
Build this script. The mouse x and mouse y blocks are in the blue "Sensing" menu.
-
Run your script. Move your mouse around the stage. What happens?
-
Stop your script by clicking the red stop sign:
-
Create a new sprite by clicking
below the stage.
-
Make the new Sprite(2) point towards Sprite using the point towards block. The video below shows how.
-
Change your script for Sprite(2) so that once the green flag is clicked, Sprite(2) will point towards Sprite forever. The video below shows how.
-
Click the green flag
and check that your script does what you intended:
- Sprite always follows your mouse.
- Sprite(2) stays in one place, but always points towards Sprite.
-
Change Sprite(2)'s code to point towards Sprite only until it is touching Sprite. The video below shows how.
-
Do the same for Sprite. Change its code to follow your mouse only until it is touching Sprite(2).
-
Test your program to see if it does what you want:
- When you click
, Sprite (the gray one) should follow your mouse and Sprite(2) should keep turning to face Sprite.
- If you bring Sprite close enough to touch Sprite(2), both sprites should stop moving.
- When you click
-
Add a move block to Sprite(2)'s script, so that it chases Sprite. You probably want a very small number like 1.
-
Test your program a few times.
-
Right now, when the sprites meet, they just stop. Make them have a conversation when they stop. You can do that by adding code, like below, to Sprite or Sprite(2). Make up your own conversation.
-
You can personalize this project in lots of ways. You can give the sprites costumes, make a longer dialogue, act out a story, add a third sprite, or even change the background on the stage.
Credits
Content adapted directly from: BJC (June 2017) U1L2 "Sprite Drawing and Interaction" and BJC (June 2019) U1L5 "Follow the Leader".