Project 441: Protect The Castle

5. Create enemy army

Add code to endlessly create more enemies that start on the right side of the screen and move towards the castle.
Starting point file for this challenge

Your goal

Steps

1. Start by hiding your original enemy sprite

After starting, hide your enemy sprite. 

2. Create a clone of your enemy

To build our enemy army we are going to clone our enemy sprite.

3. Repeat your code with a "forever" loop

We don't want to clone our enemy just once – we want it to repeat. To repeat code, we need to add a loop. Add a forever loop to keep your racer turning. You can find the forever loop in the orange "control" section.

4. Pause between each clone created

We don't want the enemy army to get too big, too fast. Adding a "wait 0.5 seconds" after a clone is created will allow us to control how fast the enemy army grows.

5. Make the clones show up when they start

Because the clones are the enemies you will be fighting, make sure they are visible when they start with a "show" block from the purple "Looks" section.

6. Have your clones start at a random place on the right edge of the screen

Your castle is on the left side of the screen, so you want your enemies to come from the right. When an enemy clone is created it should go to an X position on the very right edge of the screen, and a random Y position between the top and bottom of the screen.

7. Point towards the castle

Before your enemies can move towards your castle, they first need to face it. Use a "point towards ____ " block, found in the dark blue "Motion" section.

8. Enemies move towards the castle

Make your enemies move towards the castle. Attack!

9. Repeat until they reach the castle

Have your enemies repeatedly point towards the castle and move until they are touching the castle.