Project 265: Gravity Dodger

5. Create Clones of our Enemy

Let's make lots of copies of our enemy. We'll use cloning to create a bunch of them. In the next challenge we would like to get our enemy moving.
Starting point file for this challenge

Your goal

Steps

1. Start with the correct axis

Earlier in the project, we talked about which axis we might use to get our enemy moving. Do you remember which coordinates we will have to change for our enemy?

2. Create enemy clones

We want to create a bunch of enemies so that we can program movement automatically. Head to the "enemy" sprite, and grab a "when green flag clicked", "forever" loop, "wait 1 seconds" and a "create clone of myself" block.  Put them all together and your enemies should make clones every second.

What do you think might happen if we change the variable in the wait 1 second block? Increase the number of clones? Decrease the number of clones? We can test this later.

3. Hide clones

Now that we've created a bunch of clones, we want to make sure that they are hidden until we have them show up. Grab a "hide" block from the Looks tab and place it before the "forever" loop.  

4. Show clones

We need to get our clones to show up so they can attack the enemy.   First grab the "when I start as a clone" block from the bottom of control, then attach the "looks" block to make the clones show up.  

5. Correctly position clones

Grab a "go to x: ___ y:___ " block from the Motion Tab. Since we want our clones to begin their fall from the top of the screen, what coordinates will we change? Because the top of the screen has a Y value of 180 , we'll set our block to that as well. We also want them to be able to spawn anywhere along the width of the screen. So we'll need to use a Random Range.  Grab a "pick random 1 to 10" block from Operators, and switch it to have the same range of values as the X axis, or -240 to 240.

6. Test your enemy code

Anytime we build a large block of code, we want to make sure we test to make sure it's working as intended. At this point, your enemies should spawn, at random on the top of your screen