1 00:00:00,000 --> 00:00:03,465 [MUSIC PLAYING] 2 00:00:03,465 --> 00:00:17,553 3 00:00:17,553 --> 00:00:19,720 BRIAN YU: Welcome back, everyone, to an introduction 4 00:00:19,720 --> 00:00:21,130 to programming with Scratch. 5 00:00:21,130 --> 00:00:23,950 And last time, we introduced the world of Scratch-- 6 00:00:23,950 --> 00:00:27,220 introducing the stage and the sprites that can live on that stage. 7 00:00:27,220 --> 00:00:29,380 And saw how we could change the way the sprites 8 00:00:29,380 --> 00:00:31,960 looked by giving them costumes, and giving them some sounds, 9 00:00:31,960 --> 00:00:34,660 and also add some backdrops to our stage to make 10 00:00:34,660 --> 00:00:36,610 it look a little bit more interesting. 11 00:00:36,610 --> 00:00:40,420 But everything we were doing last time had to be done manually by ourselves-- 12 00:00:40,420 --> 00:00:44,590 if we wanted to move the sprite, I had to change the x and y values and drag 13 00:00:44,590 --> 00:00:47,060 the sprite around to a different position, for example-- 14 00:00:47,060 --> 00:00:50,320 if I wanted to change the costume, I had to click on a different costume 15 00:00:50,320 --> 00:00:51,580 that I wanted to do. 16 00:00:51,580 --> 00:00:54,730 This time we're going to start programming our Scratch projects, 17 00:00:54,730 --> 00:00:57,790 adding some code so that we can let that code run 18 00:00:57,790 --> 00:01:01,880 and manipulate what happens inside of our Scratch projects as well. 19 00:01:01,880 --> 00:01:05,440 So let's start to take a look at how we might be able to do that by opening up 20 00:01:05,440 --> 00:01:07,570 a new blank Scratch project. 21 00:01:07,570 --> 00:01:09,710 And when we do so, we'll see the stage-- 22 00:01:09,710 --> 00:01:11,080 which is pure white by default-- 23 00:01:11,080 --> 00:01:13,880 and the default Scratch Cat that's here as well. 24 00:01:13,880 --> 00:01:16,960 Now, remember from last time, if I wanted to move the Scratch Cat, 25 00:01:16,960 --> 00:01:18,560 I had two ways of doing it. 26 00:01:18,560 --> 00:01:22,510 One was to click and drag on the cat and move it around the stage 27 00:01:22,510 --> 00:01:24,670 to wherever I want the Scratch Cat to be-- 28 00:01:24,670 --> 00:01:27,820 or secondly, I could use these x and y values down here. 29 00:01:27,820 --> 00:01:31,270 I could change the x value to 0, and the y value to 0 30 00:01:31,270 --> 00:01:36,010 for example to perfectly center the cat inside of the stage. 31 00:01:36,010 --> 00:01:39,520 But this time, we're going to start to introduce these blocks that 32 00:01:39,520 --> 00:01:42,790 have been living on this left side of our Scratch window for some time now, 33 00:01:42,790 --> 00:01:45,610 but we haven't really done very much with just yet. 34 00:01:45,610 --> 00:01:47,590 And each of these blocks is going to perform 35 00:01:47,590 --> 00:01:52,480 some tasks, some action that's happening on the stage of our Scratch program-- 36 00:01:52,480 --> 00:01:55,310 and we're going to start to call these blocks functions. 37 00:01:55,310 --> 00:01:58,060 A function, in the context of Scratch, is just 38 00:01:58,060 --> 00:02:00,940 some block that performs some task. 39 00:02:00,940 --> 00:02:03,620 And we might look at this very first block, for example, 40 00:02:03,620 --> 00:02:05,830 which just says Move 10 Steps-- 41 00:02:05,830 --> 00:02:08,050 and that is a block which, as you might guess, 42 00:02:08,050 --> 00:02:11,890 has the effect of moving the cat 10 steps. 43 00:02:11,890 --> 00:02:14,590 And so, let's give it a try-- how could we use that block? 44 00:02:14,590 --> 00:02:17,410 Well, if I want to use a block as part of my project, 45 00:02:17,410 --> 00:02:20,500 I'm going to start by taking that block and dragging it 46 00:02:20,500 --> 00:02:24,610 into the Code Editor in the center part of the Scratch interface. 47 00:02:24,610 --> 00:02:26,860 So on the left hand side is, really, just this library 48 00:02:26,860 --> 00:02:29,150 where all of the blocks live to begin with, 49 00:02:29,150 --> 00:02:31,450 but if I want to use a block in my project-- 50 00:02:31,450 --> 00:02:33,520 I'm going to take the Move 10 Steps block, 51 00:02:33,520 --> 00:02:36,580 and drag it out into the main part of the Scratch interface 52 00:02:36,580 --> 00:02:38,410 and just drop it off. 53 00:02:38,410 --> 00:02:42,940 And so now, I've added my first block of code, my first function, 54 00:02:42,940 --> 00:02:44,620 into my Scratch project-- 55 00:02:44,620 --> 00:02:47,060 and to run it, I can just click on it. 56 00:02:47,060 --> 00:02:49,600 So watch what happens when I click on the Move 10 Steps-- 57 00:02:49,600 --> 00:02:53,500 notice that right now the Scratch Cat is right in the middle of the stage, 58 00:02:53,500 --> 00:02:56,080 but as soon as I click the button the cat moves. 59 00:02:56,080 --> 00:02:58,810 Just a little bit, you'll notice it moves slightly to the right, 60 00:02:58,810 --> 00:03:01,810 and you'll notice too that the position of the cat changed. 61 00:03:01,810 --> 00:03:05,650 Originally it was at 0, 0, now x is 10 and y 62 00:03:05,650 --> 00:03:07,970 is 0-- we've moved the Scratch Cat a little bit. 63 00:03:07,970 --> 00:03:11,150 And if I click it again, I can keep moving that cat-- 64 00:03:11,150 --> 00:03:16,200 and every time I click it, the cat moves 10 steps to the right. 65 00:03:16,200 --> 00:03:21,360 Notice too that in this Move 10 Steps block there's a bit of an empty gap 66 00:03:21,360 --> 00:03:24,270 here where we filled in the number 10, this 67 00:03:24,270 --> 00:03:26,740 is what we can call an input to a function. 68 00:03:26,740 --> 00:03:29,070 Functions are allowed to take inputs, information 69 00:03:29,070 --> 00:03:31,560 that those function use in order to decide 70 00:03:31,560 --> 00:03:33,330 how it is that they're going to behave. 71 00:03:33,330 --> 00:03:36,390 And the input that this function takes is a number 72 00:03:36,390 --> 00:03:40,150 indicating how many steps we would like to move-- so in this case, 73 00:03:40,150 --> 00:03:44,700 the input is 10, meaning I would like to move 10 steps, but I could change that. 74 00:03:44,700 --> 00:03:47,970 I'll drag the cat back out to give it a little more space to move, 75 00:03:47,970 --> 00:03:51,940 but I could change this input, for example, to 30. 76 00:03:51,940 --> 00:03:55,470 And now, when I click on this block, the cat moves further. 77 00:03:55,470 --> 00:03:57,570 You'll notice every time I click on it, the cat's 78 00:03:57,570 --> 00:04:00,910 moving 30 steps instead of 10 steps. 79 00:04:00,910 --> 00:04:04,560 So I can control, based on this input, how far the cat's going to move. 80 00:04:04,560 --> 00:04:07,300 And if I make it negative-- say negative 20-- 81 00:04:07,300 --> 00:04:10,880 now every time I click on the cat, the cat's going to move backwards. 82 00:04:10,880 --> 00:04:13,350 So you can decide, based on what number you write here, 83 00:04:13,350 --> 00:04:17,519 in what direction that cat is going to move. 84 00:04:17,519 --> 00:04:21,420 So this is just one block, one function that we can use inside of our Scratch 85 00:04:21,420 --> 00:04:23,590 project, but there are others as well. 86 00:04:23,590 --> 00:04:27,910 Here's one that, it says Turn 15 Degrees to the Right-- 87 00:04:27,910 --> 00:04:31,210 Turn to the Right, or Clockwise 15 Degrees. 88 00:04:31,210 --> 00:04:34,050 So if I want to use that one, let me try dragging that out 89 00:04:34,050 --> 00:04:35,340 into my Block Editor-- 90 00:04:35,340 --> 00:04:38,550 I now have two blocks the move 30 steps one, and the turn 15 degrees 91 00:04:38,550 --> 00:04:39,970 to the right one. 92 00:04:39,970 --> 00:04:44,550 And if I click this one, the Turn block, you'll notice the Scratch Cat turns-- 93 00:04:44,550 --> 00:04:48,990 every time I click on it, it rotates, changes direction by 15 degrees, 94 00:04:48,990 --> 00:04:52,080 and I can keep clicking on it turning it little by little 95 00:04:52,080 --> 00:04:57,250 until we get back to the original 90 degrees. 96 00:04:57,250 --> 00:05:01,530 So now I have two different blocks, one block that causes the cat to move, 97 00:05:01,530 --> 00:05:04,980 and one block that causes the cat to rotate-- 98 00:05:04,980 --> 00:05:07,420 and it turns out I can combine these blocks together. 99 00:05:07,420 --> 00:05:09,420 Often when you're writing programs it's not just 100 00:05:09,420 --> 00:05:12,580 going to be one instruction that you want your program to follow, 101 00:05:12,580 --> 00:05:14,910 but it's going to be some sequence of instructions 102 00:05:14,910 --> 00:05:16,390 that you want your code to follow. 103 00:05:16,390 --> 00:05:19,530 And so, these blocks can snap together, watch what happens-- 104 00:05:19,530 --> 00:05:23,910 if I take this Turn 15 Degrees block, and I drag it close to the Move 30 105 00:05:23,910 --> 00:05:24,720 Steps block-- 106 00:05:24,720 --> 00:05:26,910 you'll notice that it starts to highlight, 107 00:05:26,910 --> 00:05:31,440 and then when I release my cursor, the block just snaps into place. 108 00:05:31,440 --> 00:05:34,860 These few blocks are now connected to each other inside of a stack which 109 00:05:34,860 --> 00:05:39,360 we can call a script, and now these two blocks together 110 00:05:39,360 --> 00:05:42,360 will run together-- when we run at this stack of blocks, 111 00:05:42,360 --> 00:05:45,720 it's going to run from top to bottom running the first block, which 112 00:05:45,720 --> 00:05:48,480 is Move 30 Steps, and then the second block, which 113 00:05:48,480 --> 00:05:50,830 is Turn to the Right 15 Degrees. 114 00:05:50,830 --> 00:05:53,070 So when I click on it, watch what happens-- 115 00:05:53,070 --> 00:05:57,480 the cat moves 30 steps, but it also turns by 15 degrees. 116 00:05:57,480 --> 00:06:00,250 And I can click it again, and that'll happen again-- 117 00:06:00,250 --> 00:06:02,250 and if I keep clicking it, now you'll see we've 118 00:06:02,250 --> 00:06:04,170 got this cat moving in a nice circle. 119 00:06:04,170 --> 00:06:06,660 It's moving forward and it's rotating every time, 120 00:06:06,660 --> 00:06:10,050 and I'm doing so by every time I click on this stack running 121 00:06:10,050 --> 00:06:14,860 both of these blocks of our code. 122 00:06:14,860 --> 00:06:17,460 And so by combining together these various different blocks, 123 00:06:17,460 --> 00:06:21,180 we have the ability to create more interesting programs just by deciding 124 00:06:21,180 --> 00:06:22,920 in what sequence-- top to bottom-- 125 00:06:22,920 --> 00:06:25,530 we would like for these blocks to ultimately run in. 126 00:06:25,530 --> 00:06:28,380 And there are all sorts of other different motion blocks 127 00:06:28,380 --> 00:06:30,810 that we can use-- notice that the Scratch blocks are all 128 00:06:30,810 --> 00:06:34,170 organized into categories, and those categories are color coded. 129 00:06:34,170 --> 00:06:36,540 And all of these first set of blue blocks, 130 00:06:36,540 --> 00:06:40,410 they're all related to motion-- the movement of the cat. 131 00:06:40,410 --> 00:06:43,830 So there's one block called go to random position-- that one looks fun, 132 00:06:43,830 --> 00:06:44,460 I'll try it. 133 00:06:44,460 --> 00:06:47,760 And now, every time I click on this block, the cat 134 00:06:47,760 --> 00:06:52,902 just moves to a different random position every time. 135 00:06:52,902 --> 00:06:54,610 And maybe that's interesting, but maybe I 136 00:06:54,610 --> 00:06:57,693 don't really want the go to a random position block as part of my program. 137 00:06:57,693 --> 00:06:59,235 So if ever you decide, you know what? 138 00:06:59,235 --> 00:07:01,100 I have a block and I really don't want it-- 139 00:07:01,100 --> 00:07:03,910 there are a couple of ways to delete a block in Scratch. 140 00:07:03,910 --> 00:07:07,270 One way is you can Control-click, or right-click on the block, 141 00:07:07,270 --> 00:07:08,710 and you can just click Delete-- 142 00:07:08,710 --> 00:07:10,280 that's one way. 143 00:07:10,280 --> 00:07:13,480 The other way is I can take the block, and just drag it off to the left, 144 00:07:13,480 --> 00:07:15,280 put it back into the Library-- 145 00:07:15,280 --> 00:07:20,140 and then when I release, the block goes away there as well. 146 00:07:20,140 --> 00:07:23,760 So using this ability to now move our sprites around 147 00:07:23,760 --> 00:07:27,270 just by writing a little bit of code, by putting some blocks together-- 148 00:07:27,270 --> 00:07:30,210 let's now try and create a program that does something. 149 00:07:30,210 --> 00:07:32,910 I'm going to use a different sprite, let's not use the cat-- 150 00:07:32,910 --> 00:07:35,550 I'll go ahead and delete the cat by pressing the Trashcan 151 00:07:35,550 --> 00:07:37,650 icon next to the cat. 152 00:07:37,650 --> 00:07:40,280 But I'll choose a new sprite, let's go to animals-- 153 00:07:40,280 --> 00:07:42,870 so I have a few different options, and I think I 154 00:07:42,870 --> 00:07:45,540 like the hedgehog-- we'll go ahead and use the hedgehog. 155 00:07:45,540 --> 00:07:50,250 And what I want for the hedgehog to do is just walk around the entire stage, 156 00:07:50,250 --> 00:07:52,390 to walk in a rectangle, effectively. 157 00:07:52,390 --> 00:07:54,540 And so, let's assemble together some blocks 158 00:07:54,540 --> 00:07:57,300 to let the hedgehog do just that. 159 00:07:57,300 --> 00:08:01,590 I want the hedgehog to start in the upper left portion of the stage, 160 00:08:01,590 --> 00:08:05,460 and so that's about this x value and about that y value-- 161 00:08:05,460 --> 00:08:07,200 and I can be even more precise. 162 00:08:07,200 --> 00:08:09,540 You'll notice that the Go To block, which 163 00:08:09,540 --> 00:08:12,090 is a block that just goes to a particular position, 164 00:08:12,090 --> 00:08:16,820 will def by default include the values for wherever the sprite is currently. 165 00:08:16,820 --> 00:08:20,890 So right now it's negative 168 and 120-- 166 00:08:20,890 --> 00:08:23,110 I'm going to change this slightly, negative 180 167 00:08:23,110 --> 00:08:24,910 just to make the number a little cleaner-- 168 00:08:24,910 --> 00:08:27,960 but now this block will move this hedgehog 169 00:08:27,960 --> 00:08:31,030 to the upper left portion of the stage. 170 00:08:31,030 --> 00:08:34,890 And now if I wanted to go to the upper right portion of the stage, 171 00:08:34,890 --> 00:08:36,900 I'll use the Go To block again. 172 00:08:36,900 --> 00:08:40,590 And remember that, to control the left or right position of any given sprite, 173 00:08:40,590 --> 00:08:41,940 I can change the x value. 174 00:08:41,940 --> 00:08:45,240 The x value controls whether it's to the left or to the right-- 175 00:08:45,240 --> 00:08:48,370 negative means to the left, positive will mean to the right. 176 00:08:48,370 --> 00:08:52,930 So we'll go ahead and change it to positive 180 and then y equals 120. 177 00:08:52,930 --> 00:08:56,430 So it starts with the upper left, and then goes to the upper right, 178 00:08:56,430 --> 00:08:58,110 and I'll add one more after that. 179 00:08:58,110 --> 00:09:00,960 And I want to move it now to the lower right-- 180 00:09:00,960 --> 00:09:03,632 I want to sort of make a rectangle all around the stage-- 181 00:09:03,632 --> 00:09:06,340 in the lower right, well, that's going to be a positive x value-- 182 00:09:06,340 --> 00:09:08,130 so we'll do positive 180. 183 00:09:08,130 --> 00:09:13,290 But now a negative y value-- y control is how far up or down the hedgehog 184 00:09:13,290 --> 00:09:14,430 is going to move. 185 00:09:14,430 --> 00:09:19,800 And I'll do one more with negative for both-- negative 180, negative 120. 186 00:09:19,800 --> 00:09:23,040 That's going to be the bottom left because the x is very negative, 187 00:09:23,040 --> 00:09:24,670 and the y is very negative. 188 00:09:24,670 --> 00:09:27,630 And so what I hope this will do is cause the hedgehog 189 00:09:27,630 --> 00:09:32,880 to just move in a rectangle, go to all four corners of the stage. 190 00:09:32,880 --> 00:09:37,740 So I'll try it, I'll go ahead and click on this block and see what happens. 191 00:09:37,740 --> 00:09:40,290 All right, it didn't do exactly what I expected for it to do. 192 00:09:40,290 --> 00:09:43,197 The hedgehog just jumped immediately to the lower left, 193 00:09:43,197 --> 00:09:45,780 even though the lower left one is this last instruction here-- 194 00:09:45,780 --> 00:09:48,420 it seems to have skipped these two in the middle that 195 00:09:48,420 --> 00:09:51,790 tell it to go to the upper right and then to the lower right. 196 00:09:51,790 --> 00:09:53,400 So, what's going on? 197 00:09:53,400 --> 00:09:55,920 Well, it turns out that when a program is running, 198 00:09:55,920 --> 00:09:59,050 the computer can run our programs very, very, very quickly. 199 00:09:59,050 --> 00:10:02,130 So even though our program was going through each of these four lines one 200 00:10:02,130 --> 00:10:05,370 at a time, it happened so quickly-- it went to one location, 201 00:10:05,370 --> 00:10:08,340 then a second location, then a third location, then a fourth location-- 202 00:10:08,340 --> 00:10:11,100 that we, the human looking at this project, only 203 00:10:11,100 --> 00:10:13,060 ever saw the final location. 204 00:10:13,060 --> 00:10:17,213 We missed all three of those locations that were in between. 205 00:10:17,213 --> 00:10:19,380 And so sometimes, if I want to be able to see what's 206 00:10:19,380 --> 00:10:21,600 actually happening in a project, I need to tell 207 00:10:21,600 --> 00:10:23,310 Scratch to slow down a little bit. 208 00:10:23,310 --> 00:10:26,430 Don't just immediately go to a particular position, 209 00:10:26,430 --> 00:10:28,590 but take some time in getting there. 210 00:10:28,590 --> 00:10:32,130 And Scratch's word for this is to glide, and so what you'll notice is that-- 211 00:10:32,130 --> 00:10:35,940 in addition to just the Go To block that immediately jumps to a particular 212 00:10:35,940 --> 00:10:40,080 location, I have another motion block called Glide-- 213 00:10:40,080 --> 00:10:42,750 and this one takes three different inputs. 214 00:10:42,750 --> 00:10:48,180 This one by default says Glide 1 second to this x value and that y value-- 215 00:10:48,180 --> 00:10:51,270 and I can use that to say, take some amount of time 216 00:10:51,270 --> 00:10:55,170 to go to a particular position, and let's try that out. 217 00:10:55,170 --> 00:10:58,440 I'll head over back to my Block Editor, and I no longer 218 00:10:58,440 --> 00:11:01,177 want these bottom three blocks-- 219 00:11:01,177 --> 00:11:03,510 I'd like my starting position, but these other three I'm 220 00:11:03,510 --> 00:11:04,680 going to need to change. 221 00:11:04,680 --> 00:11:08,910 So I'll take them, drag them over into the Block Library to delete them, 222 00:11:08,910 --> 00:11:12,730 and let me now bring out a Glide block. 223 00:11:12,730 --> 00:11:18,930 Let's take one second to glide to x equals 180, y equals 120-- 224 00:11:18,930 --> 00:11:23,710 both positive-- that's going to be in the upper right portion of my stage. 225 00:11:23,710 --> 00:11:29,520 Let's take one more second to go to positive 180 for x, and negative 120 226 00:11:29,520 --> 00:11:34,650 for y-- that's to the right and down, so the bottom right portion of the stage. 227 00:11:34,650 --> 00:11:37,800 And let's take one more second to glide to negative 180, 228 00:11:37,800 --> 00:11:40,980 negative 120, which as you can see here where the hedgehog is now, 229 00:11:40,980 --> 00:11:43,603 that's the lower left corner of the stage. 230 00:11:43,603 --> 00:11:46,770 And if ever you're confused about what those numbers mean and where you are, 231 00:11:46,770 --> 00:11:50,050 you can just drag the hedgehog to the location where you want it to be-- 232 00:11:50,050 --> 00:11:53,310 and you'll be able to see what the x and y values for that 233 00:11:53,310 --> 00:11:55,080 are actually going to be. 234 00:11:55,080 --> 00:11:58,430 So now let's try to run the script-- 235 00:11:58,430 --> 00:12:01,180 I can do that, again, just by clicking on the script I want to run 236 00:12:01,180 --> 00:12:02,610 and it will run them in sequence. 237 00:12:02,610 --> 00:12:06,930 We start in one corner, and we work our way in a rectangle back to the other 238 00:12:06,930 --> 00:12:09,630 corner-- and if I wanted to end up back at the starting point, 239 00:12:09,630 --> 00:12:14,580 I can add one more Glide, and let's glide back to negative 180 and positive 240 00:12:14,580 --> 00:12:16,140 120-- that's moving up-- 241 00:12:16,140 --> 00:12:20,670 and so now when I click on the hedgehog it moves in a rectangle 242 00:12:20,670 --> 00:12:23,408 all around the stage. 243 00:12:23,408 --> 00:12:25,200 And so we've been writing programs now just 244 00:12:25,200 --> 00:12:28,950 by putting these blocks in sequence, deciding what we want our sprite to do, 245 00:12:28,950 --> 00:12:34,020 and then clicking on those blocks to run them and to see our project in action. 246 00:12:34,020 --> 00:12:35,888 And now at this point our project starting 247 00:12:35,888 --> 00:12:38,680 to get a little more complicated, and if I come back to this later, 248 00:12:38,680 --> 00:12:41,790 I might not remember exactly what I was trying to do with these blocks. 249 00:12:41,790 --> 00:12:44,590 I might not remember what all these numbers represent, 250 00:12:44,590 --> 00:12:47,910 and so Scratch gives you the ability to leave comments on your project-- 251 00:12:47,910 --> 00:12:50,190 just little sentences, short descriptions 252 00:12:50,190 --> 00:12:53,330 of what it is you were thinking, and that's helpful for two reasons. 253 00:12:53,330 --> 00:12:56,310 It's helpful, number one, if you come back to your project a little bit 254 00:12:56,310 --> 00:12:58,890 later and might not remember exactly what you were thinking-- 255 00:12:58,890 --> 00:13:00,330 you can use it as a reminder. 256 00:13:00,330 --> 00:13:03,805 And it's also helpful if someone else is reading your project-- 257 00:13:03,805 --> 00:13:06,930 they're looking at the blocks that you used and they want to understand why 258 00:13:06,930 --> 00:13:08,700 did you create the project this way-- 259 00:13:08,700 --> 00:13:11,800 you can use comments to explain as well. 260 00:13:11,800 --> 00:13:14,820 I can add a comment just by Right-clicking or Control-clicking 261 00:13:14,820 --> 00:13:17,610 on my stack, and I'll add a comment. 262 00:13:17,610 --> 00:13:22,080 And here in my comment window I'll just say these blocks 263 00:13:22,080 --> 00:13:25,950 move the sprite in a rectangle-- 264 00:13:25,950 --> 00:13:28,560 this doesn't affect how the program actually runs, 265 00:13:28,560 --> 00:13:32,160 it's just a little comment that I can collapse the offers a reminder-- 266 00:13:32,160 --> 00:13:34,260 some text that you can read a little bit later 267 00:13:34,260 --> 00:13:38,670 to understand what exactly was going on. 268 00:13:38,670 --> 00:13:41,670 So that then is what we can do with motion blocks, 269 00:13:41,670 --> 00:13:44,040 and there are other motion blocks too for changing 270 00:13:44,040 --> 00:13:46,590 what direction the sprite happens to be pointing in, 271 00:13:46,590 --> 00:13:49,200 or moving only in the x, or only in the y direction. 272 00:13:49,200 --> 00:13:51,240 And you can explore some of those options 273 00:13:51,240 --> 00:13:53,910 for what you can do with motion blocks, but let's now 274 00:13:53,910 --> 00:13:56,280 take a look at some of the other categories of blocks 275 00:13:56,280 --> 00:13:57,970 that we have access to as well. 276 00:13:57,970 --> 00:14:00,300 I'll go now to the Looks section-- 277 00:14:00,300 --> 00:14:04,090 notice that these are in a different color for a different category-- 278 00:14:04,090 --> 00:14:08,730 and here, let me drag out this Say Hello block which looks interesting. 279 00:14:08,730 --> 00:14:09,880 I'll drag it out-- 280 00:14:09,880 --> 00:14:13,088 and I'm not going to use these motion blocks anymore, so I'll get rid of them 281 00:14:13,088 --> 00:14:14,440 just by dragging them away-- 282 00:14:14,440 --> 00:14:17,220 so now I just have this one Say Hello block. 283 00:14:17,220 --> 00:14:19,350 And let me move the hedgehog to the center 284 00:14:19,350 --> 00:14:22,500 just so we can see it a little more easily-- we'll move it to x equals 0 285 00:14:22,500 --> 00:14:24,660 and y equals 0. 286 00:14:24,660 --> 00:14:27,990 If I click on Say Hello, watch what happens-- 287 00:14:27,990 --> 00:14:31,410 a little speech bubble appears next to the hedgehog 288 00:14:31,410 --> 00:14:33,780 and the hedgehog is saying hello. 289 00:14:33,780 --> 00:14:37,140 If I want it to say multiple things, I could stack multiple of these blocks 290 00:14:37,140 --> 00:14:42,113 together-- let's say hello and then say goodbye, for example, 291 00:14:42,113 --> 00:14:43,030 and see what happens-- 292 00:14:43,030 --> 00:14:48,020 I'll click on it now, I'll click on it again. 293 00:14:48,020 --> 00:14:50,833 Notice that, again, we seem to have run into a similar bug, 294 00:14:50,833 --> 00:14:53,750 a bug-- some problem with our program that we're going to need to fix. 295 00:14:53,750 --> 00:14:58,850 I wanted for my program to first say hello and then say goodbye, 296 00:14:58,850 --> 00:15:01,760 but every time I click on it, it's just saying goodbye. 297 00:15:01,760 --> 00:15:04,070 And the reason is exactly the same thing that we 298 00:15:04,070 --> 00:15:06,830 saw a moment ago with the hedgehog moving around the stage-- 299 00:15:06,830 --> 00:15:08,840 it's that Scratch's running through these blocks 300 00:15:08,840 --> 00:15:11,510 so quickly that we don't get time to see the hello, 301 00:15:11,510 --> 00:15:14,240 we just immediately see the goodbye. 302 00:15:14,240 --> 00:15:16,560 So if we want to see the hello for some time, 303 00:15:16,560 --> 00:15:20,690 we're going to need to tell Scratch to stay there for some number of seconds 304 00:15:20,690 --> 00:15:22,348 before moving on to something else-- 305 00:15:22,348 --> 00:15:24,140 and there's a block, fortunately, that will 306 00:15:24,140 --> 00:15:25,970 do that for us, which is this one here. 307 00:15:25,970 --> 00:15:28,760 Say Hello for 2 Seconds will have the effect 308 00:15:28,760 --> 00:15:32,300 of saying hello, but rather than immediately move on to the next block, 309 00:15:32,300 --> 00:15:34,520 it'll stay there for some amount of time that 310 00:15:34,520 --> 00:15:39,020 will give us a chance to read what it is that the hedgehog is actually saying. 311 00:15:39,020 --> 00:15:42,830 So let me delete these blocks dragging them off into the editor, 312 00:15:42,830 --> 00:15:46,640 and replace it with Say Hello for 2 Seconds. 313 00:15:46,640 --> 00:15:49,640 And then if I want another one, I'll drag another block out-- 314 00:15:49,640 --> 00:15:51,930 this one will be Say Goodbye for 2 Seconds, 315 00:15:51,930 --> 00:15:53,730 these are stacked on top of each other. 316 00:15:53,730 --> 00:15:58,190 So now, when I click on these blocks, the hedgehog says hello, 317 00:15:58,190 --> 00:16:01,620 and then the hedgehog says goodbye for two seconds as well. 318 00:16:01,620 --> 00:16:07,010 So we've been able to fix the bug that we've been able to create here. 319 00:16:07,010 --> 00:16:11,260 So now, Looks can affect-- not just what the character is saying, 320 00:16:11,260 --> 00:16:13,067 you can get a speech bubble to appear, you 321 00:16:13,067 --> 00:16:15,400 can get a thought bubble to appear with the Think blocks 322 00:16:15,400 --> 00:16:17,740 instead of with the Say blocks, but Looks also 323 00:16:17,740 --> 00:16:19,960 have to do with the costume for a sprite. 324 00:16:19,960 --> 00:16:22,630 Remember that last time we explored costumes and sprites, 325 00:16:22,630 --> 00:16:26,050 and how we could change the different costumes that a sprite might have. 326 00:16:26,050 --> 00:16:29,440 We did that before just by manually clicking on which costume 327 00:16:29,440 --> 00:16:31,090 we want the sprite to take on-- 328 00:16:31,090 --> 00:16:33,370 now, we can start to program it using blocks 329 00:16:33,370 --> 00:16:35,860 to decide what's going to happen in our project, 330 00:16:35,860 --> 00:16:38,905 and when our sprites are going to change their costumes. 331 00:16:38,905 --> 00:16:40,780 So let's try a different character, I'm going 332 00:16:40,780 --> 00:16:44,440 to delete my hedgehog sprite by clicking that Trash icon, 333 00:16:44,440 --> 00:16:46,720 and let's create a new sprite. 334 00:16:46,720 --> 00:16:50,470 Go into Animals, and let's choose the bear this time. 335 00:16:50,470 --> 00:16:55,450 And I'm curious as to what costumes the bear has, so I can click on the bear. 336 00:16:55,450 --> 00:16:58,600 I go into the Costumes tab and I see that the bear has 337 00:16:58,600 --> 00:17:02,830 two costumes-- there's one called Bear A that's just the bear as it 338 00:17:02,830 --> 00:17:05,680 is right now, and there's also Bear B where 339 00:17:05,680 --> 00:17:07,970 the bear is standing up a little bit. 340 00:17:07,970 --> 00:17:12,760 So we got Bear A and Bear B, and I can toggle between them in the Costumes tab 341 00:17:12,760 --> 00:17:18,490 to decide what costume the character will take on, but I can program this 342 00:17:18,490 --> 00:17:20,780 as well by assembling some blocks together. 343 00:17:20,780 --> 00:17:25,569 So let me start with a block called Switch Costume to. 344 00:17:25,569 --> 00:17:27,819 Let's start with costume bear A, with the bear 345 00:17:27,819 --> 00:17:32,120 normally the way that it is right now, and let's give it a starting position. 346 00:17:32,120 --> 00:17:38,530 When I start, I would like for it to go to let's say, x equals-- 347 00:17:38,530 --> 00:17:41,770 negative 131's OK, let's go negative 120 and negative 50, 348 00:17:41,770 --> 00:17:43,390 just to use some cleaner numbers. 349 00:17:43,390 --> 00:17:46,390 And that's going to be the starting position and the starting 350 00:17:46,390 --> 00:17:50,870 costume for the bear-- every time we click on this script, 351 00:17:50,870 --> 00:17:55,120 it's going to switch to this costume, it's going to move to this location. 352 00:17:55,120 --> 00:17:58,640 But now what I'd like for it to do is I want the bear to walk across the stage, 353 00:17:58,640 --> 00:18:00,640 and when it gets to the other side of the stage, 354 00:18:00,640 --> 00:18:02,053 the bear is going to stand up-- 355 00:18:02,053 --> 00:18:03,970 that's maybe what I'd like for the bear to do, 356 00:18:03,970 --> 00:18:05,840 and so let's do that in two steps. 357 00:18:05,840 --> 00:18:08,320 First, I want the bear to walk across the stage, 358 00:18:08,320 --> 00:18:10,330 and then I want the bear to stand up. 359 00:18:10,330 --> 00:18:11,590 Walking across the stage? 360 00:18:11,590 --> 00:18:12,730 That sounds like motion-- 361 00:18:12,730 --> 00:18:15,430 so it's going to be in the Motion section of my blocks. 362 00:18:15,430 --> 00:18:18,500 And I'll use this block, we've seen it before, 363 00:18:18,500 --> 00:18:25,930 let's take 2 seconds to glide 2 x equals 120 and y equals negative 50. 364 00:18:25,930 --> 00:18:28,963 So it's going to-- the y is not changing, it's not going up or down-- 365 00:18:28,963 --> 00:18:30,880 the only thing that's changing is the x, we're 366 00:18:30,880 --> 00:18:34,480 moving to the right along the stage. 367 00:18:34,480 --> 00:18:37,720 And after you glide there, after you take two seconds to glide there, 368 00:18:37,720 --> 00:18:39,400 now I want it to stand up-- 369 00:18:39,400 --> 00:18:41,560 that's going to be Looks, it's what it looks like-- 370 00:18:41,560 --> 00:18:43,360 what costume it's taking on-- 371 00:18:43,360 --> 00:18:48,670 and here let's go ahead and switch the costume to Bear B, so we'll try it now. 372 00:18:48,670 --> 00:18:53,080 I'll click on this script, and we start on the left-- the bear walks across, 373 00:18:53,080 --> 00:18:56,352 and when it gets to the right side of the stage, it stands up. 374 00:18:56,352 --> 00:18:58,060 And I can click it again, everything will 375 00:18:58,060 --> 00:19:01,190 reset because if we go back to costume A, we go back to the left-- 376 00:19:01,190 --> 00:19:04,210 and every time I click it, the bear goes to one side, 377 00:19:04,210 --> 00:19:07,090 and then it stands up at the end of that. 378 00:19:07,090 --> 00:19:09,190 So we can combine Motion and Looks blocks 379 00:19:09,190 --> 00:19:12,730 to start to create stories just by using these sprites 380 00:19:12,730 --> 00:19:16,177 and changing where they are and what costumes they're taking on. 381 00:19:16,177 --> 00:19:18,010 And we can make our stories more interesting 382 00:19:18,010 --> 00:19:21,230 by adding some backdrops to our stage as well, 383 00:19:21,230 --> 00:19:24,430 so let's add a couple of backdrops where we might want for our bear 384 00:19:24,430 --> 00:19:27,080 to be walking through, for example. 385 00:19:27,080 --> 00:19:29,650 So I'll go ahead and choose a new backdrop, 386 00:19:29,650 --> 00:19:34,330 and I think I'll choose the forest-- 387 00:19:34,330 --> 00:19:36,430 I'll have the bear walking through the forest. 388 00:19:36,430 --> 00:19:39,130 So that's one possible backdrop of the bear could be in-- 389 00:19:39,130 --> 00:19:41,380 I want to pick another one, though, just have a couple of options 390 00:19:41,380 --> 00:19:42,255 that I can work with. 391 00:19:42,255 --> 00:19:45,220 So I'll go back to the bottom right, choose a new backdrop, 392 00:19:45,220 --> 00:19:47,260 and this time I would like-- 393 00:19:47,260 --> 00:19:49,150 I'll scroll down near to the bottom. 394 00:19:49,150 --> 00:19:52,300 There is this one, which is called Woods and Bench, which 395 00:19:52,300 --> 00:19:54,560 I'll go ahead and click on as well. 396 00:19:54,560 --> 00:19:59,150 And so now I have the bear in the woods where there's a bench as well. 397 00:19:59,150 --> 00:20:01,750 So I've got these various different backdrops 398 00:20:01,750 --> 00:20:05,710 that I now have as part of my project, and now I'd 399 00:20:05,710 --> 00:20:09,640 like to construct a story that involves the bear moving 400 00:20:09,640 --> 00:20:11,800 through these various different backdrops-- 401 00:20:11,800 --> 00:20:15,670 and so let's try and build this story one piece at a time 402 00:20:15,670 --> 00:20:18,940 I want the story to start in the forest, so I'll get rid of these blocks 403 00:20:18,940 --> 00:20:21,160 for now-- we can add them back later-- 404 00:20:21,160 --> 00:20:25,180 but there's a block here called Switch Backdrop To, and Switch Backdrop 405 00:20:25,180 --> 00:20:29,240 To will let me choose what backdrop I want the story to have. 406 00:20:29,240 --> 00:20:31,060 So let's start in the forest-- 407 00:20:31,060 --> 00:20:33,430 I'm going to choose the backdrop called Forest, 408 00:20:33,430 --> 00:20:35,920 that's where I want the story to begin. 409 00:20:35,920 --> 00:20:41,050 And I want the bear to begin off to the left, so I can move it to where I want, 410 00:20:41,050 --> 00:20:44,680 and I can look at the x and y values to see about what the x and y values 411 00:20:44,680 --> 00:20:48,940 should be, and I'm going to have it go to let's say 412 00:20:48,940 --> 00:20:52,620 negative 120 and negative 50 again-- 413 00:20:52,620 --> 00:20:54,540 so just a choice of x and y value. 414 00:20:54,540 --> 00:20:57,440 Now when I click on this block, the bear goes to the forest, 415 00:20:57,440 --> 00:20:59,990 and it goes to a particular location. 416 00:20:59,990 --> 00:21:02,840 And I want for it to also not be standing up-- 417 00:21:02,840 --> 00:21:04,550 and so that's its costume. 418 00:21:04,550 --> 00:21:09,215 So we're going to switch its costume to Bear A, 419 00:21:09,215 --> 00:21:11,840 and these all happened so quickly that it doesn't really matter 420 00:21:11,840 --> 00:21:13,880 what order these three blocks are in. 421 00:21:13,880 --> 00:21:15,900 But it is still going to run one at a time-- 422 00:21:15,900 --> 00:21:19,580 it just happens so quickly that it looks like everything's just happening all 423 00:21:19,580 --> 00:21:22,760 at once-- where we go to the forest, we go to a particular location, 424 00:21:22,760 --> 00:21:28,670 we switch the costume to Bear A. And now what I want is for the bear to walk off 425 00:21:28,670 --> 00:21:32,630 the stage in this forest, and enter the other backdrop that we had-- 426 00:21:32,630 --> 00:21:35,250 the woods with the bench there as well. 427 00:21:35,250 --> 00:21:36,560 And so I want it to walk-- 428 00:21:36,560 --> 00:21:40,230 to do that, I can use the Glide block that we saw before. 429 00:21:40,230 --> 00:21:43,423 So let me have the bear take maybe 3 seconds to glide-- 430 00:21:43,423 --> 00:21:46,590 I don't want the y value to change, it's just going to walk left and right-- 431 00:21:46,590 --> 00:21:48,837 but the x value, I want it to walk off the stage, 432 00:21:48,837 --> 00:21:50,420 so I'm going to make this a big value. 433 00:21:50,420 --> 00:21:54,410 Something like 300 just to try and get it close to the edge of the screen-- 434 00:21:54,410 --> 00:21:59,510 and after it walks off stage, now I want to switch the backdrop. 435 00:21:59,510 --> 00:22:02,720 So I'm going to go back to Looks, let's switch the backdrop-- 436 00:22:02,720 --> 00:22:06,930 instead of going to the forest, let's now go to the woods with the bench-- 437 00:22:06,930 --> 00:22:09,590 so Switch Backdrop to Woods and Bench. 438 00:22:09,590 --> 00:22:12,258 And now, as I'm thinking about this story, 439 00:22:12,258 --> 00:22:14,300 I'm going to have the bear move off to the right, 440 00:22:14,300 --> 00:22:16,220 the backdrop is going to change, and then 441 00:22:16,220 --> 00:22:18,970 I want the bear to come out from the left side-- sort of like it's 442 00:22:18,970 --> 00:22:21,090 moving from one scene into another. 443 00:22:21,090 --> 00:22:26,960 So I need to go back to the far left of my program, 444 00:22:26,960 --> 00:22:32,270 I'll have it go to negative 300 in terms of x, which is really far to the left. 445 00:22:32,270 --> 00:22:37,400 And then let's take maybe 3 seconds to glide to the middle-- 446 00:22:37,400 --> 00:22:40,760 x equals zero, that's going to be right at the middle of the stage. 447 00:22:40,760 --> 00:22:43,550 So it's a whole bunch of blocks now, but it's telling a story. 448 00:22:43,550 --> 00:22:47,210 We start in the forest, start on the left side of the stage, 449 00:22:47,210 --> 00:22:51,110 start with costume Bear A. We're going to walk for 3 seconds 450 00:22:51,110 --> 00:22:55,550 to the right side of the stage, then switch the backdrop, go to the far left 451 00:22:55,550 --> 00:22:57,822 again, and then walk back out to the middle. 452 00:22:57,822 --> 00:22:59,780 And you can try this one block at a time to get 453 00:22:59,780 --> 00:23:02,863 a sense for how it's going to work, but when you run it all together now-- 454 00:23:02,863 --> 00:23:04,490 I'll go ahead and click on this block-- 455 00:23:04,490 --> 00:23:08,450 you see the bear move off to the right, and then it sort of shows up 456 00:23:08,450 --> 00:23:10,090 in another environment. 457 00:23:10,090 --> 00:23:13,340 We can try it again, and pay attention to which block might be happening when. 458 00:23:13,340 --> 00:23:15,440 We start in the forest on the far left, we're 459 00:23:15,440 --> 00:23:17,270 gliding three seconds to the right. 460 00:23:17,270 --> 00:23:19,730 The scene changes, we go to the far left, 461 00:23:19,730 --> 00:23:22,053 and we walk back out to the center. 462 00:23:22,053 --> 00:23:25,220 So by putting these blocks together-- and really by playing around with it-- 463 00:23:25,220 --> 00:23:28,140 you might not have gotten to exactly that on the first try-- 464 00:23:28,140 --> 00:23:31,550 but you can run the project, and if you don't like where the sprite ended up, 465 00:23:31,550 --> 00:23:33,530 you could tinker with the x and the y values, 466 00:23:33,530 --> 00:23:36,320 or how long it takes to glide from one place to another. 467 00:23:36,320 --> 00:23:38,390 But by assembling those blocks together, you 468 00:23:38,390 --> 00:23:41,960 have the ability to start to tell a story 469 00:23:41,960 --> 00:23:45,132 by creating some interesting blocks. 470 00:23:45,132 --> 00:23:47,840 And there are other blocks that you can use too inside of Looks-- 471 00:23:47,840 --> 00:23:49,520 so I'll go ahead and delete these for now-- 472 00:23:49,520 --> 00:23:51,500 but in the Looks section, we have the ability 473 00:23:51,500 --> 00:23:55,700 to change the size of the sprite if we want to make them bigger or smaller. 474 00:23:55,700 --> 00:23:58,760 We also have these blocks Show and Hide-- 475 00:23:58,760 --> 00:24:01,620 Show and Hide just control this toggle here, 476 00:24:01,620 --> 00:24:05,240 which is whether or not the sprite is actually visible on the stage. 477 00:24:05,240 --> 00:24:08,580 If I click on Hide, the bear goes away-- 478 00:24:08,580 --> 00:24:11,990 if I click on Show, the bear appears. 479 00:24:11,990 --> 00:24:14,900 So we've taken a look at how we can have the sprite move around, 480 00:24:14,900 --> 00:24:16,580 we've seen how it can change its looks. 481 00:24:16,580 --> 00:24:18,890 There's a third section here called Sound 482 00:24:18,890 --> 00:24:21,900 that can play some sound for a sprite as well. 483 00:24:21,900 --> 00:24:25,708 So for example here, there's a block called Play Sound Until Done. 484 00:24:25,708 --> 00:24:27,500 And here, if I had multiple sounds, I could 485 00:24:27,500 --> 00:24:30,620 choose from those different sounds, or I could record a new sound 486 00:24:30,620 --> 00:24:31,640 if I wanted to. 487 00:24:31,640 --> 00:24:35,450 And by clicking on this block, you'll hear a sound-- 488 00:24:35,450 --> 00:24:37,610 the sound plays. 489 00:24:37,610 --> 00:24:39,770 And so those Sound blocks can be useful too 490 00:24:39,770 --> 00:24:42,080 if you want to play sounds inside of your project. 491 00:24:42,080 --> 00:24:46,100 And one other block that I'll show now inside of Control 492 00:24:46,100 --> 00:24:48,200 is this one called Wait. 493 00:24:48,200 --> 00:24:50,280 Sometimes in your project you just want nothing 494 00:24:50,280 --> 00:24:52,280 to happen for a little bit of time, a little bit 495 00:24:52,280 --> 00:24:55,820 of a pause between things that are happening on the project. 496 00:24:55,820 --> 00:24:58,900 And here, the Wait 1 Second block will wait one second, 497 00:24:58,900 --> 00:25:01,400 and I can change the input to change how long it's waiting-- 498 00:25:01,400 --> 00:25:03,120 and then it will move on. 499 00:25:03,120 --> 00:25:05,840 So if I put these together with the Wait 1 Second block 500 00:25:05,840 --> 00:25:09,290 on top and then the Sound, well, then what will happen when I click 501 00:25:09,290 --> 00:25:14,150 is I won't hear the pop right away, but it will be one second-- 502 00:25:14,150 --> 00:25:17,090 and then you hear the pop after the end of the second. 503 00:25:17,090 --> 00:25:20,810 And so that too can give you a little bit more control over your project 504 00:25:20,810 --> 00:25:22,700 and how it's working. 505 00:25:22,700 --> 00:25:27,560 And so, let's try and create a project that uses some of those blocks. 506 00:25:27,560 --> 00:25:30,950 I am not going to use the bear, so I'll go ahead and delete the bear. 507 00:25:30,950 --> 00:25:33,230 And I'll go ahead and change my backdrop-- if I click 508 00:25:33,230 --> 00:25:36,170 on Backdrops, back to backdrop one-- which is just 509 00:25:36,170 --> 00:25:39,260 this default white backdrop for now. 510 00:25:39,260 --> 00:25:42,770 But let's add a new sprite just to have a little bit of fun with this, let's 511 00:25:42,770 --> 00:25:43,910 pick a different animal. 512 00:25:43,910 --> 00:25:47,330 And this time I will pick the duck-- 513 00:25:47,330 --> 00:25:48,440 so we got our duck. 514 00:25:48,440 --> 00:25:51,550 I want to center the duck, so I'll move it to x equals 0 515 00:25:51,550 --> 00:25:54,540 and y equals zero-- just to move it to the center of the stage. 516 00:25:54,540 --> 00:25:56,290 But here's what I'm going to do, I'm going 517 00:25:56,290 --> 00:25:59,380 to combine some of the blocks we've just been using. 518 00:25:59,380 --> 00:26:03,940 I'm going to go to Looks and hide the duck, 519 00:26:03,940 --> 00:26:07,360 then I want to wait one second-- that's under Control. 520 00:26:07,360 --> 00:26:10,540 So Control in the project, I would like it to wait one second-- 521 00:26:10,540 --> 00:26:15,820 and then back to Looks, now I want to show the duck. 522 00:26:15,820 --> 00:26:18,820 And after it shows, let's play a sound-- 523 00:26:18,820 --> 00:26:22,327 let's play the duck sound until it's done. 524 00:26:22,327 --> 00:26:24,910 And so this is going to let our duck play a little bit of hide 525 00:26:24,910 --> 00:26:27,660 and seek-- it's going to disappear, and then it's going to appear. 526 00:26:27,660 --> 00:26:31,810 So when I click on this, watch what happens on the stage-- 527 00:26:31,810 --> 00:26:36,130 it hides, it waits one second, and after one second it shows up 528 00:26:36,130 --> 00:26:38,413 and it plays the duck sound as well. 529 00:26:38,413 --> 00:26:41,080 And so you could have a lot of fun with these sounds-- right now 530 00:26:41,080 --> 00:26:44,320 the duck just has one sound, but you could add other sounds to it as well. 531 00:26:44,320 --> 00:26:48,320 You could record new sounds, you could upload a sound from your computer 532 00:26:48,320 --> 00:26:51,790 if you'd like to, and we even have the ability 533 00:26:51,790 --> 00:26:55,090 to have other blocks to play sounds-- in particular, musical notes. 534 00:26:55,090 --> 00:26:57,580 There are extensions to Scratch-- extra blocks 535 00:26:57,580 --> 00:27:01,240 that you can add into your Block library that give your Scratch 536 00:27:01,240 --> 00:27:03,768 projects a few extra features. 537 00:27:03,768 --> 00:27:06,310 And let's try that out now, I'll go ahead and delete the duck 538 00:27:06,310 --> 00:27:08,440 and we'll go back to the usual cat. 539 00:27:08,440 --> 00:27:13,690 So I'll choose a sprite and I'll just go ahead and pick the cat again, 540 00:27:13,690 --> 00:27:17,350 and move the cat back to the center. 541 00:27:17,350 --> 00:27:20,590 But notice down here in the bottom left there's this blue block 542 00:27:20,590 --> 00:27:22,460 icon with a plus next to it. 543 00:27:22,460 --> 00:27:25,233 This is where I can get to the extensions for Scratch, 544 00:27:25,233 --> 00:27:28,400 and there are all sorts of different extensions for Scratch that we can use. 545 00:27:28,400 --> 00:27:30,130 We'll take a look at a few of them today, 546 00:27:30,130 --> 00:27:33,040 but we'll start with the Music extension-- 547 00:27:33,040 --> 00:27:38,480 and the Music extension really lets you play music using Scratch box. 548 00:27:38,480 --> 00:27:45,160 So here's one called Play Note, and it's saying Play Note 60 for 0.25 beats. 549 00:27:45,160 --> 00:27:48,280 The number of beats, that's how long the notes going to be played for, 550 00:27:48,280 --> 00:27:51,555 60 is just a number corresponding to what note we're playing-- 551 00:27:51,555 --> 00:27:54,430 and if you don't happen to know what note corresponds to what number, 552 00:27:54,430 --> 00:27:55,000 that's OK. 553 00:27:55,000 --> 00:27:58,442 If you click on the 60, what you'll see is a little piano up here-- 554 00:27:58,442 --> 00:28:01,150 and if you've never played the piano, what I'm going to try to do 555 00:28:01,150 --> 00:28:03,370 is just play a scale where I'm just playing 556 00:28:03,370 --> 00:28:06,222 a whole bunch of notes in sequence that'll sound nice together. 557 00:28:06,222 --> 00:28:07,930 And I'm going to do that just by clicking 558 00:28:07,930 --> 00:28:14,830 on each of these different keys of the keyboard, 559 00:28:14,830 --> 00:28:18,520 and I noticed that every time I click on a different key, the note changes. 560 00:28:18,520 --> 00:28:22,700 Every note has a different number, and so if I want to play all of them-- 561 00:28:22,700 --> 00:28:32,440 let me drag out eight of these blocks 1, 2, 3, 4, 5, 6, 7, and 8. 562 00:28:32,440 --> 00:28:34,510 And for each one, I'll select a different key-- 563 00:28:34,510 --> 00:28:38,800 this will be the second white key, this will be the third one, 564 00:28:38,800 --> 00:28:44,080 this will be the fourth one, this one will be the fifth one, 565 00:28:44,080 --> 00:28:49,995 this one will be six, seven, and eight. 566 00:28:49,995 --> 00:28:52,120 So I've got eight blocks in sequence, each of which 567 00:28:52,120 --> 00:28:57,910 is playing a different note, and now when I click on this block 568 00:28:57,910 --> 00:28:59,827 you can hear that sort of scale. 569 00:28:59,827 --> 00:29:02,410 And there are other blocks too to change the way this sounds-- 570 00:29:02,410 --> 00:29:04,930 I can set the instrument to change to something else 571 00:29:04,930 --> 00:29:07,970 if I want it to be a guitar playing for example. 572 00:29:07,970 --> 00:29:12,880 I can set the instrument to Guitar, and now the instrument 573 00:29:12,880 --> 00:29:13,970 sounds a bit different. 574 00:29:13,970 --> 00:29:16,030 If I want it to go faster or slower, that's 575 00:29:16,030 --> 00:29:19,330 something called tempo in music-- how quickly or slowly the music 576 00:29:19,330 --> 00:29:20,350 is going to play. 577 00:29:20,350 --> 00:29:25,045 I can change it to 80, for example, and try that. 578 00:29:25,045 --> 00:29:26,170 Plays a little bit faster-- 579 00:29:26,170 --> 00:29:31,890 I could change it to something smaller like 40 580 00:29:31,890 --> 00:29:33,872 and then it plays a little bit more slowly. 581 00:29:33,872 --> 00:29:35,580 So there are a lot of blocks that you can 582 00:29:35,580 --> 00:29:37,920 use to change the way your project behaves 583 00:29:37,920 --> 00:29:40,230 to add features and interesting activities 584 00:29:40,230 --> 00:29:43,500 to what it is that you're sprites are doing on the stage. 585 00:29:43,500 --> 00:29:46,080 And I'll show you one other extension that's quite fun-- 586 00:29:46,080 --> 00:29:48,420 I'll drag the music away for now. 587 00:29:48,420 --> 00:29:52,170 But let's now try the Pen extension-- the Pen extension is 588 00:29:52,170 --> 00:29:55,050 going to let us draw with our sprite. 589 00:29:55,050 --> 00:29:56,760 And so here's how that's going to work-- 590 00:29:56,760 --> 00:30:00,840 I'm going to start the cat over on the left hand side, 591 00:30:00,840 --> 00:30:06,540 and I'm going to use this Pen Down block and the Pen Up block 592 00:30:06,540 --> 00:30:07,730 which we'll see in a moment. 593 00:30:07,730 --> 00:30:11,370 And the idea of this now is that I can draw on the stage 594 00:30:11,370 --> 00:30:14,340 just by putting a virtual pen down on the stage, 595 00:30:14,340 --> 00:30:17,370 moving the sprite across the stage, and then picking 596 00:30:17,370 --> 00:30:20,170 the pen back up at the end of it. 597 00:30:20,170 --> 00:30:23,250 And so I'm going to put the Pen Down, go into the Motion 598 00:30:23,250 --> 00:30:26,670 section of blocks-- and this time, let's try moving some number of steps. 599 00:30:26,670 --> 00:30:31,437 Maybe I'll move 30 steps, and then we'll lift the Pen Up-- 600 00:30:31,437 --> 00:30:32,520 and so let's try this now. 601 00:30:32,520 --> 00:30:37,320 A click on this block, the pen goes down, we move 30 steps 602 00:30:37,320 --> 00:30:39,490 and we move, and the pen goes back up. 603 00:30:39,490 --> 00:30:42,270 And what you notice is that, as I do this, 604 00:30:42,270 --> 00:30:47,180 the cat is still moving 30 steps every time, but it's leaving behind this line 605 00:30:47,180 --> 00:30:48,180 that the pen is drawing. 606 00:30:48,180 --> 00:30:50,670 The pen's going down, we're drawing this line, 607 00:30:50,670 --> 00:30:52,300 and then it's picking back up again. 608 00:30:52,300 --> 00:30:55,980 And the result is that you can draw shapes, you can create works of art 609 00:30:55,980 --> 00:30:59,550 just by drawing, using a sprite and moving the sprite around and making 610 00:30:59,550 --> 00:31:01,627 sure the pen is down while you're doing so. 611 00:31:01,627 --> 00:31:04,710 And when the pen is up, then it doesn't matter where you move the sprite-- 612 00:31:04,710 --> 00:31:05,970 it's not going to drop-- 613 00:31:05,970 --> 00:31:10,170 you're only going to be drawing when that pen is actually down. 614 00:31:10,170 --> 00:31:12,630 But you don't have to just create straight lines-- 615 00:31:12,630 --> 00:31:15,360 before, when we were first doing motion with the cat, 616 00:31:15,360 --> 00:31:16,950 we had the cat move in a circle. 617 00:31:16,950 --> 00:31:18,780 Remember, when we were having it move a little bit, 618 00:31:18,780 --> 00:31:21,072 and then rotate a little bit, and then move and rotate, 619 00:31:21,072 --> 00:31:22,870 ultimately move in a circle. 620 00:31:22,870 --> 00:31:26,520 So if we wanted to draw a circle on the Scratch stage, 621 00:31:26,520 --> 00:31:28,890 we could do that by combining our code that we 622 00:31:28,890 --> 00:31:32,190 use to move the cat in a circle along with the code 623 00:31:32,190 --> 00:31:35,550 for bringing the pen up, and bringing the pen back down. 624 00:31:35,550 --> 00:31:41,100 And the way we did that is by moving, but then-- before the pen goes up-- 625 00:31:41,100 --> 00:31:48,480 let's also have the cat turn by 15 degrees and then lift the pen back up. 626 00:31:48,480 --> 00:31:51,715 And it'll have the cat start around the top of the circle, 627 00:31:51,715 --> 00:31:53,590 and that's probably where I want it to begin. 628 00:31:53,590 --> 00:31:55,680 But before I begin, I want to erase what's 629 00:31:55,680 --> 00:31:58,050 currently been drawn onto the stage, and that's 630 00:31:58,050 --> 00:31:59,940 back in the Pen section of the blocks. 631 00:31:59,940 --> 00:32:02,460 There's one block just called Erase All, that's 632 00:32:02,460 --> 00:32:05,700 going to erase anything that's been drawn onto the stage. 633 00:32:05,700 --> 00:32:07,710 So I'll click that, that erases the pen-- 634 00:32:07,710 --> 00:32:10,080 and you'll notice there are other different Pen 635 00:32:10,080 --> 00:32:12,900 blocks I can use to change what color the pen is drawing in, 636 00:32:12,900 --> 00:32:16,560 to change the size of the pen, the thickness with which I'm drawing. 637 00:32:16,560 --> 00:32:18,870 But I'll just stick with the default for now, 638 00:32:18,870 --> 00:32:23,250 and we'll put the pen down, move 30 steps and rotate, move 30 steps 639 00:32:23,250 --> 00:32:24,300 and rotate-- 640 00:32:24,300 --> 00:32:29,460 and as I do this over and over again, the cat's moving, and moving. 641 00:32:29,460 --> 00:32:33,090 And what you see is that we end up drawing a circle on the stage 642 00:32:33,090 --> 00:32:34,500 just by putting the pen down-- 643 00:32:34,500 --> 00:32:37,260 and every time we move, we rotate a little bit, 644 00:32:37,260 --> 00:32:42,270 and the effect is that we can use the Pen tool to draw out this circle. 645 00:32:42,270 --> 00:32:45,690 And so those are just some of the blocks that you can use in Scratch. 646 00:32:45,690 --> 00:32:49,380 We saw blocks in the Motion category for moving the sprite around 647 00:32:49,380 --> 00:32:52,650 in order to move it left, right, up, or down, or rotate it, for example. 648 00:32:52,650 --> 00:32:57,353 The Looks section of blocks we can use to change the costume of a sprite 649 00:32:57,353 --> 00:32:59,520 to make it look a little bit different, or to change 650 00:32:59,520 --> 00:33:03,600 the backdrop that we see in the stage inside of our Scratch program. 651 00:33:03,600 --> 00:33:06,990 Or even to make our sprites speak up by saying something or thinking 652 00:33:06,990 --> 00:33:09,570 something inside of a speech, or a thought bubble. 653 00:33:09,570 --> 00:33:12,480 We took a look at some Control blocks-- the ability 654 00:33:12,480 --> 00:33:16,470 to wait some number of seconds, the ability to play sounds, the ability 655 00:33:16,470 --> 00:33:20,820 to make music, and use the pen in order to draw images and create works of art. 656 00:33:20,820 --> 00:33:23,880 And we can do all of that just by taking these blocks 657 00:33:23,880 --> 00:33:27,240 and putting them together in the sequence we want them to be in. 658 00:33:27,240 --> 00:33:30,810 And, ultimately using that, you can create some really interesting programs 659 00:33:30,810 --> 00:33:31,830 with Scratch. 660 00:33:31,830 --> 00:33:34,720 That's it for an introduction to programming with Scratch for today. 661 00:33:34,720 --> 00:33:37,553 Next time, we'll take a look at how we can use these sorts of blocks 662 00:33:37,553 --> 00:33:39,930 and take our Scratch Block projects even further. 663 00:33:39,930 --> 00:33:42,000 We'll see you next time. 664 00:33:42,000 --> 00:33:43,000