In this video,
you will program the game to spawn enemies,
that bounce around the screen.
First, add and resize an enemy.
Make your enemy's sprite smaller.
Next, program the sprite to bounce around the screen.
First, move the sprite forward.
Then, move the sprite forward forever.
Next, program the sprite to bounce if it touches the edge
with an an if on edge bounce walk.
Program the sprite to turn a random amount before starting
to move to make your sprite's movement unexpected.
And finally, add a one flag click event to start the motion.
Next, clone or spawn new enemies.
In previous games, you may have manually copied a sprite,
but one of the great things about computer science
is that you can program the computer to do things for you.
You could manually right click
to copy new sprite each time you
wanted to make the game harder,
but, it's much easier to get the computer
to make clones for you.
Drag out a create clone of myself block,
and a when I start as a clone block from the control menu.
Place the code you previously created
onto the when I start as a clone event.
And add the create clones myself block to the flag event.
Now this reads when the flag is clicked,
create a clone of myself.
Then, when I start as a clone, bounce off the walls.
Click the flag to test.
Awesome, when the flag is clicked, a clone starts.
To create more clones, click control,
and place a repeat loop around the create clone
of myself block.
Whoa, that's so cool!
Try another value in repeat loop.
This example uses a value of 100.
Whoa, that's a lot!
The instructions program here are so complex,
the computer cannot continue to run this code.
Try making the number something smaller,
that the computer can run.
This example uses 10.
Test your code.
There's still a bug in this program.
There's a sprite on the screen that doesn't move.
Right now, only the clones are programmed to move.
To fix this, hide the sprite that isn't moving,
and show only the clones.
Add a hide block to the end
of your when flag clicked block stack.
This will hide the first sprite,
but it will also hide all of the clones.
Add a show block to the when I start as a clone event,
so all the clones will appear on the stage.
Test it out again.
And that's it, now, all of the clones move.
In the next video, you'll program the sprites
to clone only if a point is scored.
Now, it's your turn.
Add an enemy sprite, and
create a clone of the enemy when the flag is clicked.
Add a when I start as a clone event
to the code you already created for bouncing the sprite.
Then, hide the sprite and show the clones.
Sign in to save your project and track your progress.