1 00:00:00,000 --> 00:00:02,650 >> SPEAKER 1: Let's take a look at a program that I've been working on that 2 00:00:02,650 --> 00:00:05,510 has two sprites, each of which has its own script. 3 00:00:05,510 --> 00:00:08,710 The biggest takeaway of this program is that you can indeed have not only 4 00:00:08,710 --> 00:00:12,170 two sprites, but those sprite scripts can run in parallel. 5 00:00:12,170 --> 00:00:15,760 That is, at the same time, which is to say that's from scratch gives us 6 00:00:15,760 --> 00:00:20,430 multithreaded programming environment, whereby two things can happen 7 00:00:20,430 --> 00:00:22,250 literally at the same time. 8 00:00:22,250 --> 00:00:24,910 >> Now here we have first our bird sprite. 9 00:00:24,910 --> 00:00:27,450 And notice that this bird has one script. 10 00:00:27,450 --> 00:00:28,740 Let's zoom in. 11 00:00:28,740 --> 00:00:32,200 Now according to this script, when the green flag is clicked the bird is 12 00:00:32,200 --> 00:00:35,250 going to move to negative 150, 150. 13 00:00:35,250 --> 00:00:37,790 So really, the top left-hand corner of the stage. 14 00:00:37,790 --> 00:00:40,820 And then he's going to point downward at a 45-degree angle. 15 00:00:40,820 --> 00:00:42,790 >> Then he's forever going to do the following. 16 00:00:42,790 --> 00:00:45,790 If he is not touching the cat, he's going to move three 17 00:00:45,790 --> 00:00:47,770 steps or three pixels. 18 00:00:47,770 --> 00:00:50,810 And if he's on the edge of the stage, he's going to bounce. 19 00:00:50,810 --> 00:00:53,630 And then he is going to do that again and again and again. 20 00:00:53,630 --> 00:00:56,400 In other words, this bird is going to flutter around the stage. 21 00:00:56,400 --> 00:00:59,260 >> Meanwhile, the cat is going to be doing the following. 22 00:00:59,260 --> 00:01:03,180 He's going to start at negative 160, negative 160. 23 00:01:03,180 --> 00:01:05,690 So really, the bottom left-hand corner of the screen. 24 00:01:05,690 --> 00:01:09,360 And he's going to pick a random direction in which to point. 25 00:01:09,360 --> 00:01:11,350 >> Thereafter, he's going to forever do the following. 26 00:01:11,350 --> 00:01:15,620 If he's touching the bird, he's going to play the lion sound and roar, and 27 00:01:15,620 --> 00:01:18,750 then he's going to stop, thereby ending this animation. 28 00:01:18,750 --> 00:01:22,940 Otherwise he's going to point himself toward the bird and move one step. 29 00:01:22,940 --> 00:01:26,830 >> In other words, the cat is going to perpetually follow this bird, but not 30 00:01:26,830 --> 00:01:30,330 quite at the same pace, thereby giving the bird a bit of an advantage. 31 00:01:30,330 --> 00:01:33,360 Well, let's see what happens when we do run these scripts. 32 00:01:33,360 --> 00:01:36,190 >> Let's go ahead and click our green flag. 33 00:01:36,190 --> 00:01:38,040 And they're off. 34 00:01:38,040 --> 00:01:40,250 Notice that the bird is coming up on the edge of the stage. 35 00:01:40,250 --> 00:01:41,760 And, indeed, he bounces. 36 00:01:41,760 --> 00:01:43,570 And again, bounces off that edge. 37 00:01:43,570 --> 00:01:46,350 >> The cat, meanwhile, is really homing in on this bird. 38 00:01:46,350 --> 00:01:49,530 He's almost about to catch him after one more bounce it seems. 39 00:01:49,530 --> 00:01:50,096 And-- 40 00:01:50,096 --> 00:01:50,432 >> [ROAR] 41 00:01:50,432 --> 00:01:51,830 SPEAKER 1: Indeed, he's been caught. 42 00:01:51,830 --> 00:01:53,893