Students will be able to...
- Demonstrate the difference between sprite and global variables.
- Explain how cloning and prototyping simplify similar sprites in the same script.
- Create prototype sprites and clones of the prototype sprite.
- Explain the difference between a "master" sprite and a "clone" sprite.
- Do now 5.2
- 5.2 slide deck
- Lab 5.2 - Lots of balls(docx) (pdf)
- Test out the lab on student machines before class (cloning can bring the web browser to a crawl on some machines).
- Snap! tips: 0, 3, 5, 9, 12, 17
Duration | Description |
---|---|
5 minutes | Welcome, attendance, bell work, announcements |
15 minutes | Introductory discussion |
30 minutes | Lab activity |
15 minutes | Debrief and wrap-up |
Show students a brief video demonstrating space invaders.
<iframe class="markdeep" width="560" height="315" src="https://www.youtube.com/embed/kR2fjwr-TzA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>Ask students to think about how we create all the “invaders”?
- Answer with current knowledge: make one invader sprite, and copy it many times while adjusting the copies as necessary.
Ask what might go wrong or be bad about this approach.
- If anything in an invader changes, it will need to be changed many times.
- Lots of sprites clogging up the program that are all basically doing the same thing.
Introduce cloning as the automated way of doing the manual copying.
Demonstrate how to create a clone using:
Point out that clones inherit all aspects of the "master" or "prototype" sprite, including scripts.
Students should complete the Lots of balls lab.
- This lab will be repeating much of what was in the lesson. This is intentional.
- Students should focus on ensuring they are differentiating between "master" sprites and "clone" sprites, and that the stage is serving as the main "driver" for the program.
Advanced students can attempt to assign properties to clones (color, size, etc.) so that not all clones look alike. To do this, they will need to use a global variable to temporary hold the value that can be "claimed" by the clone.
Struggling students should focus on just creating a single clone from the prototype and not worry about creating multiple clones.