Jul 6 at 12am - Jul 17 at 11:59pm
This assignment was locked Jul 17 at 11:59pm.
THIS LAB IS OPTIONAL (0 Points of your grade) - BUT - IT IS WORTH 5 POINTS OF EXTRA CREDIT
In this lab, you will use cloning to create many identical sprites without having to reprogram each one individually.
Part 1 - Follow the bouncing ball
Create a SNAP program that contains a single sprite. When the green flag is clicked, the sprite should go to the center of the stage, pick a random direction, and start moving in the chosen direction at a speed (move) of 5. If the sprite hits a wall, it should bounce off and keep moving.
Modify the program to be controlled by the stage rather than by the sprite itself. When the spacebar is pressed, the stage should broadcast a message that triggers the sprite's movement. Pressing the spacebar again should restart the sprite's movement, including a new speed and new direction.
Consider - what would you need to do to add a second bouncing ball that behaved in the same way to your program? What about 10 balls? You could just keep copying the sprite. But 100 balls? And then you wanted to change the speed of all the balls in the program after you had created all 100? For that, we have clones.
Part 2 - Clones!
Modify your program so that, instead of a single sprite restarting each time the spacebar is pressed, a new clone of that sprite is created. You'll want to use the and blocks in place of and .
Look to see what happens to the original ("master") sprite each time the spacebar is pressed. Consider what we will use the original for, now that we are cloning. Like - do we even want to see it?
Modify the program so that the original ("master") sprite hides at the beginning of the program and each new sprite appears when it is created.
BONUS: Assign each clone a different value for some properties, such as speed, color, or size. Try controlling these values from the master sprite rather than having each clone choose its own.
Can't change a rubric once you've started using it.