Following with Sprites

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.

  1. "U1L2-SpriteChase"Create a new project called U1L2-SpriteChase
  2. Read and think about this script before you build it. What do you expect it to do?
    Mouse X Reporter and Mouse Y Reporter report the mouse's location on the stage. You can find them in the Sensing palette.

    Follow That Mouse Script

  3. To stop this script, click the red stop sign stop button.
    Now build the script and run it. Move your mouse around the stage while the program is running.
  4. Talk with Your Partner Does the program work the way you expected?
  5. Create a second sprite that turns toward the first sprite. Follow these instructions or watch the animation below.
    1. Click on the "add a new Turtle sprite" button just below the stage: add a new turtle sprite
    2. The new sprite appears on the stage, and a button to select it appears underneath the stage. This sprite is brand new so it has no scripts. You will need to drag in blocks to tell it what to do. If you want to see any sprite's scripts, click on its button below the stage.
    3. Add a line of code to Sprite(2) to make it point towards Sprite.
    The project name in the animation doesn't match the name they're told to use.
    getting a new sprite
  6. Pair Programming Swap
  7. Change your script for Sprite(2) so that once the green flag is clicked, it will point towards Sprite forever. Follow these instructions or watch the animation below.

    pointing towards Sprite forever

  8. While a script is running, its border is highlighted. Some scripts run so quickly that you may not notice the brief border flash. This script runs forever, so it's easier to notice the highlighted border.
  9. Talk with Your Partner Click green-flag button and check that your script does what you had intended it to:
      Both sprites' scripts start with Whengreen-flag buttonclicked. So, when green-flag button is clicked, both sprites' scripts run.
    • Sprite always follows your mouse around the stage.
    • Sprite(2) stays in the same place, but always points toward Sprite.