Hi, welcome back Christy here again. Today we're learning about sprite interaction, how to create and control multiple sprites. So let's code.
So far we've only used one sprite at a time. But what if we want to use multiple sprites at once? Well, how will the sprites work together and affect each other? Let's find out how this works in Scratch.
Let's first start by creating a new sprite. Click on the Cat Icon on the bottom right of the screen, and then either add a new sprite or click the paint icon to create your own. As you can see, on the right side of the screen, our new sprite has been added. So cute.
Select the sprite you want to write code for in the bottom right of the screen, and then drag the blocks you want into the scripts area. To control the next Sprite, select the second sprite in the bottom right of the screen and write code for it. Please note which sprite each of the code blocks is connected to this is important.
In this example, we have both sprites moving forward and bouncing against the walls after the green flag is clicked. Now, what if we want to have the sprites interact with each other? In this exercise, we want one sprite to bounce at a random angle around the screen. And we want the other to bounce back and forth in a straight line. When the two sprites touch each other, we want the program to stop. Here's an example. Let's think about how we might code this.
What blocks do we need? Well, we need to use the BOUNCE BLOCK, THE RANDOM BLOCK, THE TURN BLOCK to generate an angle, the TOUCHING BLOCK, the FOREVER BLOCK and the STOP BLOCK. Here's what the code might look like.
Let's move on to the exercises and quizzes. Now it's your turn. I'll see you in the next lesson.