Following the Leader
At the end of this lesson students will be able to:
- make Actors follow the mouse as well as each other.
Let me show you the coding blocks we’re going to be using in this lesson.
- Point to each block as it is mentioned
- Teachers may want to build a project with the blocks already laid out or drag them onto the stage as they talk about them?
The blocks we will be learning about in this lesson are ‘point towards mouse pointer’, ‘go to x y’, ‘pick random’, ‘screen left’, ‘screen right’, ‘screen bottom’, ‘screen top’, ‘show’, and ‘hide’.
1-2. Follow the Leader (DIY project)
- In this tutorial, your students will program a racer to follow their mouse pointer or finger, and also program an evil spaceship to follow the racer. The key here is using the “point towards” block to orient the racer towards the mouse pointer or touch location, and orient the spaceship towards the racer.
- Tell your students to experiment with the “move pixels” block in the evil spaceship’s code. What happens when the evil spaceship moves faster than the racer? Is the “following” effect more pronounced when the spaceship moves considerably slower than the racer?
3-4. Collect Items (DIY project)
- Students will program the orb to disappear when touched by the racer and reappear randomly at another spot.
- This involves using the “pick random” parameter to find a random location on the screen, and using “hide” and “show” blocks in the orb’s code.
- Have your students change the “game gain point” sound to whatever they like.
5. Collect the Orbs (puzzle)
In this puzzle we need to program the orbs to disappear when the racer touches them.
- Read the text and play the example.
- Click on Get Started.
Step 1How can we make the racer follow the mouse pointer?
Yes. We need to use the ‘point towards mouse pointer’ blocks inside a repeat loop to cause the spaceship to continually move in the direction of the mouse. Are there any questions?
- Wait for responses from students.
Now, how can we make the orbs disappear when touched by the spaceship?
Yes. For each orb we need to use the ‘when touching’ blocks and type in ‘racer’. Are there any questions?
- Wait for responses from students.
- Have students practice building the code.
6-7. Chase Game (DIY project)
- Students will program a more complete chasing game.
- They will begin by programming their Racer to follow their mouse pointer. After that, they will program the Bad Ship to chase behind the Racer.
- Students will finish up the project by adding code that makes the orb disappear and reappear in a random location after the Racer reaches it.
8-9. Survive the Graveyard (DIY project)
- Your students will create an advanced game with some similarities to the racer chasing games, but a different look and feel.
- The first task is programming the Hero to run around and follow the mouse pointer or the user's finger. The Hero must also be programmed to attack the zombies.
- The zombies should be destroyed after they are attacked by the Hero as well.
- Students will complete the graveyard game by programming the ghost to follow the Hero around, and end the game if they touch.
In this lesson we learned more about how to make an actor point towards and follow a mouse pointer. We also learned how to make an actor point towards and follow another actor.
- Check for understanding and ask if there are any questions.
If you made a spiderweb in the previous lesson, maybe now you can add a bug that gets caught in the web. You could guide the bug with the mouse and have the spider chase it around the web.
Be creative. What chase scenario can you come up with to practice following the mouse?
Re-motivate and Close
Did you enjoy learning how to create your own chase games? Keep practicing the skills you learned in this lesson by continuing to improve on your own games. Try adding extra actors that chase each other. Can you make actors reappear in random locations after being touched?
Now, let’s get ready for the next lesson called Changing Actor Size where we will learn how to program actors to change their size whenever the spacebar is pressed.