1 00:00:00,000 --> 00:00:03,458 [MUSIC PLAYING] 2 00:00:03,458 --> 00:00:16,993 3 00:00:16,993 --> 00:00:19,160 BRIAN YU: Welcome back, everyone, to an introduction 4 00:00:19,160 --> 00:00:20,510 to programming with Scratch. 5 00:00:20,510 --> 00:00:24,050 And last time we took a look at Events, things that can happen-- 6 00:00:24,050 --> 00:00:26,660 like us pressing the green flag, or clicking a button, 7 00:00:26,660 --> 00:00:28,730 or pressing a key on the keyboard-- and letting 8 00:00:28,730 --> 00:00:31,670 our Scratch project respond to those events. 9 00:00:31,670 --> 00:00:32,930 And how do they respond? 10 00:00:32,930 --> 00:00:34,970 Well, they respond with Functions, those blocks 11 00:00:34,970 --> 00:00:38,480 that we stacked on top of each other to let our sprites or the stage 12 00:00:38,480 --> 00:00:40,590 respond in some way. 13 00:00:40,590 --> 00:00:43,970 And so let's take a closer look today at those Functions-- 14 00:00:43,970 --> 00:00:47,600 we've seen already that we can have the cat move, for example, 15 00:00:47,600 --> 00:00:49,040 just by using a block like this-- 16 00:00:49,040 --> 00:00:52,940 Move 10 Steps-- such that when I click on this block, 17 00:00:52,940 --> 00:00:55,580 the cat moves by 10 steps. 18 00:00:55,580 --> 00:00:59,090 And we discussed before that these Functions, these blocks, 19 00:00:59,090 --> 00:01:00,470 can accept input. 20 00:01:00,470 --> 00:01:02,750 Input in the form of whatever goes in this oval 21 00:01:02,750 --> 00:01:05,630 here, which is 10 by default-- but we were able to change that. 22 00:01:05,630 --> 00:01:09,470 If we wanted the cat to move more steps or fewer steps, 23 00:01:09,470 --> 00:01:14,450 we were able to change the number here to control how many steps the cat was 24 00:01:14,450 --> 00:01:15,530 ultimately going to move. 25 00:01:15,530 --> 00:01:19,730 That, again, was called an input, and the actual information that goes inside 26 00:01:19,730 --> 00:01:22,160 of that input we might call a value. 27 00:01:22,160 --> 00:01:24,733 A value is just some piece of information-- in this case, 28 00:01:24,733 --> 00:01:26,900 it could be something like a number, like the number 29 00:01:26,900 --> 00:01:28,760 of steps to move-- like the number 10. 30 00:01:28,760 --> 00:01:31,590 But a value could also be words, for example-- 31 00:01:31,590 --> 00:01:34,340 you might recall that we were able to make our sprite speak up 32 00:01:34,340 --> 00:01:36,710 if we go into the Look section and choose 33 00:01:36,710 --> 00:01:39,830 a block like Say Hello For 2 Seconds. 34 00:01:39,830 --> 00:01:43,640 Here, the word "Hello" is a value as well-- values are just 35 00:01:43,640 --> 00:01:48,030 pieces of information that our program might be able to use. 36 00:01:48,030 --> 00:01:51,950 And it turns out, in addition to us just being able to type values 37 00:01:51,950 --> 00:01:55,940 into these oval-shaped spaces inside of our Scratch functions, 38 00:01:55,940 --> 00:02:00,170 there are some blocks in Scratch that are themselves values, 39 00:02:00,170 --> 00:02:03,030 and today we're going to be exploring those. 40 00:02:03,030 --> 00:02:07,130 So if you notice here in the Motion section of blocks, most of these blocks 41 00:02:07,130 --> 00:02:08,690 are all a very similar shape. 42 00:02:08,690 --> 00:02:12,048 Some might be longer or shorter, but they're all kind of rectangular, 43 00:02:12,048 --> 00:02:14,090 and they have these indentations so that they can 44 00:02:14,090 --> 00:02:16,730 stack on top of each other visually. 45 00:02:16,730 --> 00:02:21,110 But you'll notice that down here, at the bottom of the Motion section, 46 00:02:21,110 --> 00:02:24,180 we have a few blocks that are a different shape. 47 00:02:24,180 --> 00:02:26,760 This one's called X Position, this one's called Y Position, 48 00:02:26,760 --> 00:02:29,390 this one's called Direction-- they're not rectangular, 49 00:02:29,390 --> 00:02:31,020 they don't stack on top of each other. 50 00:02:31,020 --> 00:02:32,990 And in fact, we wouldn't be able to just drag 51 00:02:32,990 --> 00:02:36,590 this underneath the existing blocks and expect them to snap together. 52 00:02:36,590 --> 00:02:38,660 Scratch is a little bit smart, and it's only 53 00:02:38,660 --> 00:02:40,890 going to allow blocks to connect to each other 54 00:02:40,890 --> 00:02:44,510 if it makes logical sense for those blocks to connect to each other. 55 00:02:44,510 --> 00:02:47,910 Instead, these three blocks are oval shaped-- 56 00:02:47,910 --> 00:02:50,420 they're not functions anymore, they're values. 57 00:02:50,420 --> 00:02:54,470 They're pieces of information that represent something about the Scratch 58 00:02:54,470 --> 00:02:56,060 project that we're currently running. 59 00:02:56,060 --> 00:02:58,310 This block is a value that represents what 60 00:02:58,310 --> 00:03:02,300 is the x position of a current sprite-- how far to the left or to the right 61 00:03:02,300 --> 00:03:03,350 is that sprite. 62 00:03:03,350 --> 00:03:05,510 This block represents the y position, how far 63 00:03:05,510 --> 00:03:07,740 up or down that sprite happens to be. 64 00:03:07,740 --> 00:03:11,540 And this block represents the direction-- what direction that sprite 65 00:03:11,540 --> 00:03:12,920 happens to be facing. 66 00:03:12,920 --> 00:03:15,170 And because they're oval-shaped, we can't just 67 00:03:15,170 --> 00:03:19,490 add them above or below the script, but we can put them inside 68 00:03:19,490 --> 00:03:21,140 of these oval-shaped inputs. 69 00:03:21,140 --> 00:03:24,170 Notice the inputs to all of the functions are oval-shaped-- 70 00:03:24,170 --> 00:03:27,320 and therefore, because these values are also oval-shaped, 71 00:03:27,320 --> 00:03:29,960 they can snap together that way instead. 72 00:03:29,960 --> 00:03:34,590 We're going to be putting a block inside of the input to another block, 73 00:03:34,590 --> 00:03:36,750 so let's see what that looks like. 74 00:03:36,750 --> 00:03:41,270 I'll go ahead and get rid of the Move 10 Steps-- we'll just keep the Say Hello. 75 00:03:41,270 --> 00:03:43,910 But instead of saying hello for two seconds, 76 00:03:43,910 --> 00:03:49,820 let's have the sprite say it's x position for two seconds-- 77 00:03:49,820 --> 00:03:56,210 meaning how far to the left or to the right is the cat right now. 78 00:03:56,210 --> 00:03:59,150 And I'll have this happen when the flag is clicked, so add an Event-- 79 00:03:59,150 --> 00:04:03,980 when the flag is clicked, go ahead and say your x position for two seconds, 80 00:04:03,980 --> 00:04:06,330 and now when I click the flag to start the program-- 81 00:04:06,330 --> 00:04:08,360 let's see what happens. 82 00:04:08,360 --> 00:04:10,100 The cat says 10-- 83 00:04:10,100 --> 00:04:12,380 it's saying its current x position, which we can 84 00:04:12,380 --> 00:04:14,840 see down here it's exposition is 10. 85 00:04:14,840 --> 00:04:18,547 And if we drag the cat far to the right, for example, now click the green flag, 86 00:04:18,547 --> 00:04:20,630 and you'll see it's going to say a bigger number-- 87 00:04:20,630 --> 00:04:22,250 175. 88 00:04:22,250 --> 00:04:24,620 And if we drag the cat far to the left, now it's 89 00:04:24,620 --> 00:04:26,300 going to say a smaller number-- 90 00:04:26,300 --> 00:04:30,140 negative 161. 91 00:04:30,140 --> 00:04:34,610 And if we want, we can have it say both its x position and its y position. 92 00:04:34,610 --> 00:04:38,870 I'll add another Say block, and instead of saying the x position, 93 00:04:38,870 --> 00:04:44,390 let's go back into Motion, and let's choose y position. 94 00:04:44,390 --> 00:04:47,180 Now it's going to say it's x value for two seconds, 95 00:04:47,180 --> 00:04:49,300 and then it's y value for two seconds. 96 00:04:49,300 --> 00:04:51,330 I'll click the green flag-- 97 00:04:51,330 --> 00:04:55,730 it says negative 161, negative 13. 98 00:04:55,730 --> 00:05:00,140 And so these values, these oval-shaped x position and y position blocks, 99 00:05:00,140 --> 00:05:02,090 they're no longer functions-- these are just 100 00:05:02,090 --> 00:05:06,500 values that we can put in any spot inside of our functions 101 00:05:06,500 --> 00:05:08,210 where they have an oval-shaped input. 102 00:05:08,210 --> 00:05:11,960 Where we could add something into that oval to describe how what 103 00:05:11,960 --> 00:05:15,320 we want the cat, in this case, to say. 104 00:05:15,320 --> 00:05:18,030 And right now, it's saying the x position for two seconds 105 00:05:18,030 --> 00:05:21,130 and then it's y value for two seconds, which is fine, 106 00:05:21,130 --> 00:05:23,490 but maybe I'd like the cat to say them together. 107 00:05:23,490 --> 00:05:26,170 To say, like, here's where I am right now. 108 00:05:26,170 --> 00:05:29,280 And to do that, I need some way of combining these values-- 109 00:05:29,280 --> 00:05:33,932 I need to combine the x location and the y location of this cat. 110 00:05:33,932 --> 00:05:35,640 And here's where we're going to introduce 111 00:05:35,640 --> 00:05:39,180 another new concept within Scratch, and within programming more generally-- 112 00:05:39,180 --> 00:05:41,640 and those are Operators. 113 00:05:41,640 --> 00:05:46,170 An Operator is going to accept values as its own input, 114 00:05:46,170 --> 00:05:49,590 and the Operator is going to produce a new value for us. 115 00:05:49,590 --> 00:05:53,580 And so one Operator, for example, this very first one is +. 116 00:05:53,580 --> 00:05:57,120 It will take two values, maybe like 1 and 2 and we add them together 117 00:05:57,120 --> 00:05:58,500 and it's going to give us 3. 118 00:05:58,500 --> 00:05:59,970 So, what would that look like? 119 00:05:59,970 --> 00:06:03,450 I'll disconnect these for now just so we can try something a little different. 120 00:06:03,450 --> 00:06:07,140 I'll go into Looks, have it say something for 2 seconds, 121 00:06:07,140 --> 00:06:12,990 but instead of saying hello for two seconds, let's have it say 1 plus 2 122 00:06:12,990 --> 00:06:15,240 for two seconds. 123 00:06:15,240 --> 00:06:19,380 Now I press the green flag to start the program and the cat says 3-- 124 00:06:19,380 --> 00:06:24,190 this operator, this green block here, is performing the task of addition. 125 00:06:24,190 --> 00:06:29,640 It accepts two inputs, two values of its own as inputs, the 1 and the 2-- 126 00:06:29,640 --> 00:06:33,660 and then this entire oval block is going to calculate what is 1 plus 2, 127 00:06:33,660 --> 00:06:34,920 it's going to be 3. 128 00:06:34,920 --> 00:06:37,440 And because that's inside of the Say block, 129 00:06:37,440 --> 00:06:42,820 now the cat is going to say the number 3 for two seconds. 130 00:06:42,820 --> 00:06:45,730 And so we have blocks to perform math like addition, subtraction, 131 00:06:45,730 --> 00:06:47,500 multiplication, and division. 132 00:06:47,500 --> 00:06:50,250 We have other blocks, as well, and the one I'm interested in right 133 00:06:50,250 --> 00:06:52,920 now is this one down here called Join. 134 00:06:52,920 --> 00:06:55,710 Right now, it says Join Apple and Banana-- 135 00:06:55,710 --> 00:06:59,340 you could use this for any characters we might want to join together. 136 00:06:59,340 --> 00:07:03,960 And what it's going to do is it's going to take two different values, 137 00:07:03,960 --> 00:07:07,440 and it's just going to combine them together into one. 138 00:07:07,440 --> 00:07:12,180 And so I would like to combine together the x location of the cat in addition 139 00:07:12,180 --> 00:07:13,890 to the y location of the cat-- 140 00:07:13,890 --> 00:07:18,930 and so let's use the Join operator to do just that. 141 00:07:18,930 --> 00:07:21,630 I'll get rid of this block that was just doing some math 142 00:07:21,630 --> 00:07:25,980 and instead take this Join block, and I want to join together 143 00:07:25,980 --> 00:07:29,550 the X Position and the Y Position. 144 00:07:29,550 --> 00:07:33,450 Notice that these ovals snap into place because the two inputs in the join 145 00:07:33,450 --> 00:07:36,150 block are also oval-shaped-- 146 00:07:36,150 --> 00:07:38,640 now I don't need two Says, I only need one. 147 00:07:38,640 --> 00:07:42,960 And let's take this Join block and put it inside of the Say block-- 148 00:07:42,960 --> 00:07:46,650 and notice the Say block too will grow in order to make room 149 00:07:46,650 --> 00:07:48,330 for the block that's inside of it now. 150 00:07:48,330 --> 00:07:51,690 And now I have a block inside of a block inside of another block-- 151 00:07:51,690 --> 00:07:54,240 the same block has this Join block in it, 152 00:07:54,240 --> 00:07:59,680 and inside the Join block are the x and y values as well. 153 00:07:59,680 --> 00:08:03,810 And so now when I press the green flag, notice what happens-- 154 00:08:03,810 --> 00:08:09,600 it says negative 161 negative 13, and it was all kind of mashed together, 155 00:08:09,600 --> 00:08:12,220 and I might not even know exactly where that coordinate is. 156 00:08:12,220 --> 00:08:18,073 So if I wanted to, I could change the backdrop-- let's give myself a grid, 157 00:08:18,073 --> 00:08:20,490 I think there's a grid backdrop if I do a search for grid. 158 00:08:20,490 --> 00:08:22,140 Yeah, here's an xy grid-- 159 00:08:22,140 --> 00:08:26,910 so I can see on an xy grid kind of where the cat is on this plane. 160 00:08:26,910 --> 00:08:28,800 I'll press it again-- 161 00:08:28,800 --> 00:08:30,679 minus 161 minus 13. 162 00:08:30,679 --> 00:08:32,429 That's fine, but maybe if you've used math 163 00:08:32,429 --> 00:08:36,502 before, you're more used to x comma y, you see one value comma 164 00:08:36,502 --> 00:08:39,210 another value instead of them just being right next to each other 165 00:08:39,210 --> 00:08:41,870 without even a space in between them. 166 00:08:41,870 --> 00:08:42,870 So how could we do that? 167 00:08:42,870 --> 00:08:47,160 How could we add a comma just to separate the x value from the y value 168 00:08:47,160 --> 00:08:48,840 a little bit more? 169 00:08:48,840 --> 00:08:52,282 Well, I can use another Join-- 170 00:08:52,282 --> 00:08:54,240 this is going to look a little bit complicated, 171 00:08:54,240 --> 00:08:55,680 but here's what I'm going to do. 172 00:08:55,680 --> 00:09:00,030 Instead of joining together the X Position and the Y Position, 173 00:09:00,030 --> 00:09:06,720 let me first take a comma and a space, and join that with the Y Position. 174 00:09:06,720 --> 00:09:11,185 And then put that Join inside of the input to the other Join-- 175 00:09:11,185 --> 00:09:13,560 so this is starting to get a little bit more complicated, 176 00:09:13,560 --> 00:09:15,480 but let's try and break down exactly what's happening here. 177 00:09:15,480 --> 00:09:18,300 I've got a lot of blocks nested inside of other blocks, 178 00:09:18,300 --> 00:09:20,520 but here I'm saying something-- what am I saying? 179 00:09:20,520 --> 00:09:22,560 Well, I'm joining together these two things-- 180 00:09:22,560 --> 00:09:27,152 I'm joining the x value of the cat and this block here. 181 00:09:27,152 --> 00:09:28,110 And what is this block? 182 00:09:28,110 --> 00:09:32,640 Well, that block is joining together a comma and the y value 183 00:09:32,640 --> 00:09:34,720 of wherever the cat happens to be. 184 00:09:34,720 --> 00:09:38,570 So taken all together, what does this big oval now do? 185 00:09:38,570 --> 00:09:42,330 Well, it's going to take the X Position, and then take a comma, and then 186 00:09:42,330 --> 00:09:45,600 the Y Position, and that all together is going to be 187 00:09:45,600 --> 00:09:48,945 what goes inside of the Say block. 188 00:09:48,945 --> 00:09:51,570 So we're starting to nest a lot of blocks inside of each other, 189 00:09:51,570 --> 00:09:54,240 but the net result is that, if I take the cat 190 00:09:54,240 --> 00:09:59,400 and move it to near the middle of the stage, for example-- 191 00:09:59,400 --> 00:10:00,750 press the green flag-- 192 00:10:00,750 --> 00:10:05,040 it's going to say 4 comma 3, that's where in the world it happens to be. 193 00:10:05,040 --> 00:10:08,140 If I move its location somewhere else and press the flag again, 194 00:10:08,140 --> 00:10:10,720 it's going to give me some different numbers. 195 00:10:10,720 --> 00:10:15,580 But now it's saying it all at once, one value comma another value. 196 00:10:15,580 --> 00:10:17,820 And if I wanted to make this a complete sentence, 197 00:10:17,820 --> 00:10:23,430 I can even add one more Join n-- let me say, I am at-- 198 00:10:23,430 --> 00:10:27,570 and then take this whole big Join block that Says position, and put that 199 00:10:27,570 --> 00:10:32,340 on the other side of the Join, and now have the cat say all of this. 200 00:10:32,340 --> 00:10:39,000 "I am at x comma y," and so now if I drag it down here, it says, 201 00:10:39,000 --> 00:10:44,700 "I am at negative 30 comma negative 96. " If I drag it here, the cat says, 202 00:10:44,700 --> 00:10:51,300 "I am at 49 comma 61," and so using these values and operators we can start 203 00:10:51,300 --> 00:10:56,100 to combine values together and start to make some more interesting projects 204 00:10:56,100 --> 00:10:57,730 as well. 205 00:10:57,730 --> 00:11:00,930 And we did this just now with the X Position and the Y Position, 206 00:11:00,930 --> 00:11:04,140 but there's also this Direction block that we could do this with too. 207 00:11:04,140 --> 00:11:06,870 If we wanted the cat to, not only say where it is, 208 00:11:06,870 --> 00:11:10,620 but also what direction it's facing, you could imagine using that Direction 209 00:11:10,620 --> 00:11:14,260 block-- so the cat could say, "I am pointing at 90 degree angle," 210 00:11:14,260 --> 00:11:17,230 or "I'm pointing at a 45 degree angle" for example-- 211 00:11:17,230 --> 00:11:22,983 and we could have it use that value inside of its blocks as well. 212 00:11:22,983 --> 00:11:24,900 So let's try something a little different now, 213 00:11:24,900 --> 00:11:27,460 we've taken a look at these motion values-- 214 00:11:27,460 --> 00:11:29,490 let's look at what other values we might have. 215 00:11:29,490 --> 00:11:32,340 I'll keep scrolling down inside of Scratch's interface, 216 00:11:32,340 --> 00:11:35,430 and under the Look section we have a whole bunch of other functions 217 00:11:35,430 --> 00:11:37,620 that we've used before-- we've used the Say block, 218 00:11:37,620 --> 00:11:40,920 we've used the Switch Costume, and Switch Backdrop blocks, 219 00:11:40,920 --> 00:11:42,940 we've used Change Size. 220 00:11:42,940 --> 00:11:44,910 Notice down below though-- 221 00:11:44,910 --> 00:11:49,500 we also have a couple of blocks that are not the shape of the normal Functions, 222 00:11:49,500 --> 00:11:52,770 they're instead oval-shaped meaning they are values. 223 00:11:52,770 --> 00:11:56,520 We have one for the Costume number, we have one for the Backdrop number, 224 00:11:56,520 --> 00:11:58,800 and we have one just called Size-- 225 00:11:58,800 --> 00:12:02,580 and Size in this case is going to represent how big or small 226 00:12:02,580 --> 00:12:03,360 our sprite is. 227 00:12:03,360 --> 00:12:06,180 Remember that our sprites start out at 100% size, 228 00:12:06,180 --> 00:12:08,790 but we have already seen how we can make them smaller 229 00:12:08,790 --> 00:12:10,720 or we can make them bigger. 230 00:12:10,720 --> 00:12:13,350 So, when might we want to use something like the Size block 231 00:12:13,350 --> 00:12:17,220 to know how big or small a particular sprite is? 232 00:12:17,220 --> 00:12:18,520 Well, let's take an example-- 233 00:12:18,520 --> 00:12:20,760 let's imagine we're not using the cat anymore, 234 00:12:20,760 --> 00:12:24,630 I'll go ahead and delete the cat, and I'll change the backdrop back 235 00:12:24,630 --> 00:12:27,090 to our plain white backdrop. 236 00:12:27,090 --> 00:12:33,570 Let's pick out a new sprite, go into Animals, and let's grab the hedgehog. 237 00:12:33,570 --> 00:12:36,060 And if I wanted the hedgehog to move, I want 238 00:12:36,060 --> 00:12:39,480 the hedgehog to move every time I press the right arrow, for example-- 239 00:12:39,480 --> 00:12:41,100 we saw last time how we could do that. 240 00:12:41,100 --> 00:12:44,310 I add an Event saying, not when the Space key is pressed, 241 00:12:44,310 --> 00:12:46,500 but when the Right arrow is pressed. 242 00:12:46,500 --> 00:12:51,810 Now I want the hedgehog to move 10 steps, so drag it over to the left, 243 00:12:51,810 --> 00:12:55,380 I press the right arrow, and it's moving. 244 00:12:55,380 --> 00:12:59,340 And that seems like a reasonable pace for a hedgehog of about that size, 245 00:12:59,340 --> 00:13:03,570 but if I made the hedgehog much smaller and sprite 50%. 246 00:13:03,570 --> 00:13:05,812 And now have it move-- 247 00:13:05,812 --> 00:13:07,770 notice that it's moving-- because it's smaller, 248 00:13:07,770 --> 00:13:09,810 it's still moving 10 steps every time. 249 00:13:09,810 --> 00:13:12,960 It's moving maybe a little bit fast for how big it is-- 250 00:13:12,960 --> 00:13:15,540 I might like to change this so that my program's 251 00:13:15,540 --> 00:13:20,010 a little bit more responsive to how big or small a sprite happens to be. 252 00:13:20,010 --> 00:13:23,070 If a sprite is bigger, then it's probably taking bigger steps, 253 00:13:23,070 --> 00:13:24,980 so I want it to move more every time. 254 00:13:24,980 --> 00:13:26,730 And if a sprite a smaller, well, then it's 255 00:13:26,730 --> 00:13:32,110 probably taking smaller steps, so I want it to move less every time. 256 00:13:32,110 --> 00:13:34,560 And so instead of moving 10 steps-- 257 00:13:34,560 --> 00:13:39,360 I'll change the size back to 100, but instead of moving 10 steps, 258 00:13:39,360 --> 00:13:43,320 let's have it move Size steps. 259 00:13:43,320 --> 00:13:48,090 Size is a value representing how big or small the hedgehog is, 260 00:13:48,090 --> 00:13:51,600 and I'll drag it inside this oval shape input-- it snaps right into place 261 00:13:51,600 --> 00:13:53,310 because it is oval-sized. 262 00:13:53,310 --> 00:13:55,990 And now, instead of moving 10 steps every time, 263 00:13:55,990 --> 00:13:59,040 it's going to move a number of steps dependent upon the size 264 00:13:59,040 --> 00:14:00,300 of the hedgehog. 265 00:14:00,300 --> 00:14:05,460 And so because this hedgehog is 100% size, now when I press the Right arrow, 266 00:14:05,460 --> 00:14:08,050 it's moving 100 steps every time. 267 00:14:08,050 --> 00:14:11,380 That's probably too fast, I want to cut down on this a little bit-- 268 00:14:11,380 --> 00:14:14,950 and here is where we can start to do maybe a little bit of math. 269 00:14:14,950 --> 00:14:18,300 Let's go into Operators and let's use Division-- 270 00:14:18,300 --> 00:14:20,760 Division I can use to cut down on the size of something 271 00:14:20,760 --> 00:14:22,200 make the numbers smaller. 272 00:14:22,200 --> 00:14:26,070 Let's do Size divided by 10, you could play around with this 273 00:14:26,070 --> 00:14:28,122 and decide what you want it to be. 274 00:14:28,122 --> 00:14:29,580 And so, now what's going to happen? 275 00:14:29,580 --> 00:14:32,070 Let's try and analyze the math of this a little bit-- 276 00:14:32,070 --> 00:14:36,540 if the size of the hedgehog is 100, meaning it's full size to begin with, 277 00:14:36,540 --> 00:14:38,820 then every time I press the Right arrow key-- 278 00:14:38,820 --> 00:14:41,700 we're going to move Size divided by 10 steps. 279 00:14:41,700 --> 00:14:45,640 The size is 100 divided by 10 is just 10, 280 00:14:45,640 --> 00:14:49,013 and so the hedgehog is going to move 10 steps. 281 00:14:49,013 --> 00:14:50,430 What if the hedgehog were smaller? 282 00:14:50,430 --> 00:14:52,230 What if the size was 50? 283 00:14:52,230 --> 00:14:55,677 Well, then the hedgehog is going to move 50 divided by 10 steps, 284 00:14:55,677 --> 00:14:57,510 meaning it's only going to move five steps-- 285 00:14:57,510 --> 00:14:59,795 smaller steps for a smaller hedgehog. 286 00:14:59,795 --> 00:15:01,170 What if the hedgehog were bigger? 287 00:15:01,170 --> 00:15:03,090 What if it was size of 200? 288 00:15:03,090 --> 00:15:06,310 Well, then it's going to move at 200 divided by 10 steps-- 289 00:15:06,310 --> 00:15:09,630 in other words, it's going to move 20 steps every time 290 00:15:09,630 --> 00:15:10,620 we hit the Right arrow. 291 00:15:10,620 --> 00:15:14,970 It's moving more steps because it's a bigger animal. 292 00:15:14,970 --> 00:15:19,640 And so now when I press Right arrow, it's moving 10 steps every time. 293 00:15:19,640 --> 00:15:23,750 If I change the size of the hedgehog and make it a little bit smaller, size 15, 294 00:15:23,750 --> 00:15:28,140 now it's moving only five steps every time I press the Right arrow. 295 00:15:28,140 --> 00:15:31,700 And if I make it bigger, make it size 200, 296 00:15:31,700 --> 00:15:39,240 now it's going to be moving 20 steps every time I press the arrow as well. 297 00:15:39,240 --> 00:15:43,220 And so we can start to use these values to get information about our sprite-- 298 00:15:43,220 --> 00:15:45,020 where it is in the world, how big or small 299 00:15:45,020 --> 00:15:48,500 it is, and use that to affect the way that our program behaves. 300 00:15:48,500 --> 00:15:50,840 By using, not just values that we type in, 301 00:15:50,840 --> 00:15:57,660 but by using values that are given to us as part of Scratch to make it work too. 302 00:15:57,660 --> 00:16:00,500 And so, I'll go ahead and change the size back to 100. 303 00:16:00,500 --> 00:16:04,100 I'll go ahead and center the hedgehog again so it's back in the middle, 304 00:16:04,100 --> 00:16:06,650 and let's try something else fun in these Operators. 305 00:16:06,650 --> 00:16:09,080 One thing I'm noticing in these Operators 306 00:16:09,080 --> 00:16:11,750 is that we can do math-- we've seen like addition, and division, 307 00:16:11,750 --> 00:16:14,390 and there's also subtraction, and multiplication. 308 00:16:14,390 --> 00:16:17,300 We've seen how we can join two words together 309 00:16:17,300 --> 00:16:19,973 with this Join Apple and Banana block. 310 00:16:19,973 --> 00:16:21,890 There's another block that looks interesting-- 311 00:16:21,890 --> 00:16:25,310 Pick Random 1 To 10. 312 00:16:25,310 --> 00:16:27,290 Pick Random 1 To 10 is a type of block that's 313 00:16:27,290 --> 00:16:30,680 going to let us add a little bit of randomness into our project. 314 00:16:30,680 --> 00:16:34,520 Right now, most of our projects are just doing the same thing every time-- 315 00:16:34,520 --> 00:16:36,990 unless we use the Random Position movement, 316 00:16:36,990 --> 00:16:38,540 which we used a couple of times. 317 00:16:38,540 --> 00:16:41,600 But Pick Random will just pick a random number for us 318 00:16:41,600 --> 00:16:44,060 so that we can let the project do something 319 00:16:44,060 --> 00:16:47,280 different each time we run the project. 320 00:16:47,280 --> 00:16:50,810 And so just for fun I might say, when the flag is clicked-- 321 00:16:50,810 --> 00:16:53,000 let's go ahead and go to Motion-- 322 00:16:53,000 --> 00:16:57,020 and have the hedgehog point in a particular direction. 323 00:16:57,020 --> 00:16:59,970 And instead of always pointing in direction 90, 324 00:16:59,970 --> 00:17:05,660 let's have the hedgehog pick a random number between 0 and 90. 325 00:17:05,660 --> 00:17:10,010 And we've put that value inside of this Point In Direction block-- 326 00:17:10,010 --> 00:17:13,530 and so, now every time I press the green flag, what's going to happen? 327 00:17:13,530 --> 00:17:16,460 We're going to pick a random number between 0 and 90, 328 00:17:16,460 --> 00:17:19,832 and the hedgehog is then going to point in that direction. 329 00:17:19,832 --> 00:17:20,540 So I can try it-- 330 00:17:20,540 --> 00:17:24,530 I'll press the green flag, and the hedgehog tilts slightly. 331 00:17:24,530 --> 00:17:27,502 I'll press it again, now it's facing a totally different direction-- 332 00:17:27,502 --> 00:17:29,960 I'll press it again, now it's facing a different direction. 333 00:17:29,960 --> 00:17:32,450 And every time I press the flag, it's going 334 00:17:32,450 --> 00:17:35,330 to calculate a random number between 0 and 90, 335 00:17:35,330 --> 00:17:40,110 and the hedgehog is then going to point in that direction. 336 00:17:40,110 --> 00:17:42,737 And so randomness can add a little bit of fun to your projects 337 00:17:42,737 --> 00:17:44,570 as well so that there's something surprising 338 00:17:44,570 --> 00:17:47,090 every time you run the project-- where it's not always going 339 00:17:47,090 --> 00:17:51,650 to be the same thing every single time. 340 00:17:51,650 --> 00:17:55,520 All right, so we've seen some values that we can use inside of Motion, 341 00:17:55,520 --> 00:17:57,680 and inside of Looks, and we've seen some Operators 342 00:17:57,680 --> 00:18:00,320 we can use to do some math to join things together, 343 00:18:00,320 --> 00:18:01,980 to pick some random numbers. 344 00:18:01,980 --> 00:18:04,372 If we keep looking around for other values-- 345 00:18:04,372 --> 00:18:06,080 I'll go ahead and scroll, and I'm looking 346 00:18:06,080 --> 00:18:08,060 for anything that might be shaped like an oval, 347 00:18:08,060 --> 00:18:10,530 potentially, that I might want to use. 348 00:18:10,530 --> 00:18:15,200 One thing that catches my attention is this value here-- 349 00:18:15,200 --> 00:18:16,478 it's called Timer. 350 00:18:16,478 --> 00:18:19,520 And you might recall from last time that we have used the Timer already-- 351 00:18:19,520 --> 00:18:22,130 every Scratch project has a built-in timer that's 352 00:18:22,130 --> 00:18:27,770 counting how many seconds have passed since we started running the project. 353 00:18:27,770 --> 00:18:31,040 And we used that before to control the timing of our different sprites 354 00:18:31,040 --> 00:18:33,240 that existed in this project as well. 355 00:18:33,240 --> 00:18:36,290 But we can also use this if we just want to know how long it's 356 00:18:36,290 --> 00:18:38,790 been since we started the project. 357 00:18:38,790 --> 00:18:42,080 I'll go ahead and get rid of these blocks here, 358 00:18:42,080 --> 00:18:45,500 let's use the Timer value for something, let's say-- let's go to Events-- 359 00:18:45,500 --> 00:18:48,770 when the sprite is clicked, when I click on the hedgehog-- let's go ahead 360 00:18:48,770 --> 00:18:54,080 and have the hedgehog say whatever the value of the Timer is. 361 00:18:54,080 --> 00:18:57,170 I'll go ahead and change the hedgehog's direction back to 90 362 00:18:57,170 --> 00:19:00,320 so it's still facing the right again, and now I'll 363 00:19:00,320 --> 00:19:04,160 press the green flag to start the project-- the project's now started. 364 00:19:04,160 --> 00:19:06,710 And now when I click on the hedgehog, it says, 365 00:19:06,710 --> 00:19:10,730 "it's been 4.45 seconds since we started the project. " 366 00:19:10,730 --> 00:19:15,530 And I'll press it again, "it's been 9.90 seconds since we started the project, " 367 00:19:15,530 --> 00:19:18,820 and honestly now I don't really need to know that number in all that much 368 00:19:18,820 --> 00:19:19,320 detail. 369 00:19:19,320 --> 00:19:24,350 I don't care if it's 9.90 versus 9.91 for example I just want to know has it 370 00:19:24,350 --> 00:19:27,780 been nine seconds or 10 seconds or 11 seconds, for example. 371 00:19:27,780 --> 00:19:31,730 And so what I could do in this case is go back to Operators, 372 00:19:31,730 --> 00:19:35,000 and there's an Operator here called Round. 373 00:19:35,000 --> 00:19:38,270 And Round, If you're familiar with it for math, just takes a number 374 00:19:38,270 --> 00:19:40,890 and rounds it to a whole number. 375 00:19:40,890 --> 00:19:43,280 So if I have 9.9, it's just going to say, 376 00:19:43,280 --> 00:19:47,480 you know what, let's call that 10-- it rounds up to 10 seconds. 377 00:19:47,480 --> 00:19:51,230 So we'll take the Timer, put it inside of the Round Operator, 378 00:19:51,230 --> 00:19:54,590 and we'll take the Round Operator and put it inside of the Say block. 379 00:19:54,590 --> 00:19:58,490 Now we're saying the rounded version of the timer for two seconds. 380 00:19:58,490 --> 00:20:03,140 Now I click on it and it's been 58 seconds now, not 58 point something, 381 00:20:03,140 --> 00:20:03,740 for example. 382 00:20:03,740 --> 00:20:07,580 I wait a few more seconds, now it's been 63 seconds 383 00:20:07,580 --> 00:20:09,930 since the start of the project. 384 00:20:09,930 --> 00:20:12,050 And so these values give you a lot ability 385 00:20:12,050 --> 00:20:15,050 to know something about what's going on inside of the project. 386 00:20:15,050 --> 00:20:18,180 And Scratch just figures out what each of these values 387 00:20:18,180 --> 00:20:21,180 should be-- it knows what the x position and y position 388 00:20:21,180 --> 00:20:22,960 and size is for any given sprite. 389 00:20:22,960 --> 00:20:26,140 It knows how long it's been since we started running the project, 390 00:20:26,140 --> 00:20:28,560 so it knows what the value of the timer should be. 391 00:20:28,560 --> 00:20:32,760 But there are some other values that the user can have a little bit more control 392 00:20:32,760 --> 00:20:35,850 over as well, and that's where our projects can get even more 393 00:20:35,850 --> 00:20:38,500 interactive and even more interesting. 394 00:20:38,500 --> 00:20:39,990 Let's take a look now-- 395 00:20:39,990 --> 00:20:45,060 I'll go ahead and get rid of the hedgehog and we'll bring back the cat. 396 00:20:45,060 --> 00:20:48,510 Let's take a look now at the Sensing section of blocks, which 397 00:20:48,510 --> 00:20:50,460 we haven't really looked at just yet. 398 00:20:50,460 --> 00:20:52,470 But notice this block here-- 399 00:20:52,470 --> 00:20:55,652 Ask What's Your Name And Wait-- 400 00:20:55,652 --> 00:20:56,860 this is an interesting block. 401 00:20:56,860 --> 00:21:00,120 It is a function, it's shaped like all of those other function blocks, 402 00:21:00,120 --> 00:21:02,880 and it seems to be asking the user a question. 403 00:21:02,880 --> 00:21:05,640 It's asking something like, what's your name? 404 00:21:05,640 --> 00:21:08,040 And What's Your Name here, this, if you'll recall, 405 00:21:08,040 --> 00:21:09,570 is the input to the function. 406 00:21:09,570 --> 00:21:11,880 Anything in this oval shape in a function 407 00:21:11,880 --> 00:21:13,920 block-- that's an input to the function. 408 00:21:13,920 --> 00:21:16,800 It's telling this function what question should you ask-- 409 00:21:16,800 --> 00:21:18,810 by default, the question is, what's your name? 410 00:21:18,810 --> 00:21:22,860 But the question might be different, we could ask whatever question we want, 411 00:21:22,860 --> 00:21:25,270 but the user is going to type in an answer. 412 00:21:25,270 --> 00:21:29,460 And that answer is going to then be the output of this function, 413 00:21:29,460 --> 00:21:32,340 and we haven't really seen outputs too much just yet. 414 00:21:32,340 --> 00:21:35,130 These outputs, also called return values, 415 00:21:35,130 --> 00:21:39,280 are values that come back after we run a function. 416 00:21:39,280 --> 00:21:41,430 And it turns out this Ask What's Your Name and Wait 417 00:21:41,430 --> 00:21:43,620 block has a return value-- 418 00:21:43,620 --> 00:21:48,180 and the return value is this value here, which is called answer. 419 00:21:48,180 --> 00:21:51,030 This block here, answer, is going to be a value that 420 00:21:51,030 --> 00:21:57,790 stores whatever it is the user typed in in response to that question. 421 00:21:57,790 --> 00:22:01,170 So we can ask the user a question, and based on what the user answers, 422 00:22:01,170 --> 00:22:05,830 we can use that answer later on in our program somewhere. 423 00:22:05,830 --> 00:22:11,490 So let's give that a try, let's try that out and see what we can do. 424 00:22:11,490 --> 00:22:14,640 I want to say that, when the green flag is clicked when I first 425 00:22:14,640 --> 00:22:19,560 start this project, let's go to something 426 00:22:19,560 --> 00:22:23,970 and choose the Ask What's Your Name and Wait block. 427 00:22:23,970 --> 00:22:27,870 And when you do that, let's go ahead and just say it back to them. 428 00:22:27,870 --> 00:22:30,547 I'll go to Say, Say Hello for 2 Seconds. 429 00:22:30,547 --> 00:22:32,880 I don't want you to say "hello" for two seconds though-- 430 00:22:32,880 --> 00:22:36,750 I want you to say the answer for two seconds. 431 00:22:36,750 --> 00:22:40,140 Whatever it is the user typed in when they were asked that question, 432 00:22:40,140 --> 00:22:43,620 that's going to be this return value called Answer. 433 00:22:43,620 --> 00:22:46,350 And we're now using Answer later in the project 434 00:22:46,350 --> 00:22:51,360 to say the answer for two seconds-- so now when I run this program, 435 00:22:51,360 --> 00:22:54,270 the cat asks the question "what's your name?" 436 00:22:54,270 --> 00:22:57,420 And we haven't moved on in the program yet-- the program is waiting, 437 00:22:57,420 --> 00:22:59,430 and it's waiting for me to answer the question. 438 00:22:59,430 --> 00:23:05,760 It's waiting for me to type in my name, I'll type in Brian, I'll press Return, 439 00:23:05,760 --> 00:23:08,613 and the cat now says my name back to me. 440 00:23:08,613 --> 00:23:11,280 And if I wanted to, I could make it a little bit more friendly-- 441 00:23:11,280 --> 00:23:14,190 I can go into Operators and let's use that Join again. 442 00:23:14,190 --> 00:23:21,820 Instead of saying answer, let's have it say Hello comma and then the answer. 443 00:23:21,820 --> 00:23:25,110 So I'm using that Join Operator to combine two values together 444 00:23:25,110 --> 00:23:27,970 and I'm using that inside of the Say block. 445 00:23:27,970 --> 00:23:33,270 Now, when I press the green flag, "what's your name? " I say, Brian, 446 00:23:33,270 --> 00:23:37,210 and the cat says, "hello, Brian," for example. 447 00:23:37,210 --> 00:23:41,760 And so we can ask the user questions and use their answer inside of the program, 448 00:23:41,760 --> 00:23:44,070 and that opens up a lot of interesting doors 449 00:23:44,070 --> 00:23:46,770 for what it is that we can do with our Scratch project. 450 00:23:46,770 --> 00:23:51,360 Remember, before, we'd been using Move to move a certain number of steps, 451 00:23:51,360 --> 00:23:54,720 and we can say move 10 steps, or move 20 steps for example. 452 00:23:54,720 --> 00:24:00,510 Let's ask the user how far we want to move, let's ask, how many steps? 453 00:24:00,510 --> 00:24:04,410 And then instead of moving 10 steps, we'll go into Sensing, 454 00:24:04,410 --> 00:24:05,550 we'll grab the answer-- 455 00:24:05,550 --> 00:24:08,590 that return value, and let's Move Answer Steps. 456 00:24:08,590 --> 00:24:12,810 Whatever the user typed in, that's how many steps I want to move. 457 00:24:12,810 --> 00:24:16,600 So I'll drag the cat back to the left hand side, I'll press the flag-- 458 00:24:16,600 --> 00:24:21,600 "how many steps? " Or if I type in 10, we move 10 steps. 459 00:24:21,600 --> 00:24:22,690 Let's try it again-- 460 00:24:22,690 --> 00:24:25,860 "how many steps? " I'll type in 50, something bigger. 461 00:24:25,860 --> 00:24:27,540 Now we move 50 steps. 462 00:24:27,540 --> 00:24:30,240 Press it again-- "how many steps? " Let's try 200, 463 00:24:30,240 --> 00:24:33,340 and the cat moves 200 steps when I type in that number. 464 00:24:33,340 --> 00:24:37,200 So whatever number I type in, that's the Return value of the Function 465 00:24:37,200 --> 00:24:38,910 that becomes the Answer. 466 00:24:38,910 --> 00:24:42,510 And because I'm using the Answer inside of this Move some number of steps 467 00:24:42,510 --> 00:24:45,150 block, that's going to result in me-- the user-- 468 00:24:45,150 --> 00:24:48,420 being able to control as by typing it into my keyboard 469 00:24:48,420 --> 00:24:51,750 how far I actually want the cat to move. 470 00:24:51,750 --> 00:24:54,210 And I can use this for other blocks too-- 471 00:24:54,210 --> 00:24:57,030 we've seen before that we have the ability 472 00:24:57,030 --> 00:25:01,260 to set the x value to something, to make it go somewhere, 473 00:25:01,260 --> 00:25:03,930 and we've also seen that we can set the y value to something 474 00:25:03,930 --> 00:25:05,470 to have it go somewhere else. 475 00:25:05,470 --> 00:25:13,680 So I can ask Pick x, and then let's set x to that answer. 476 00:25:13,680 --> 00:25:21,910 Then ask Pick y and set y to the new answer-- 477 00:25:21,910 --> 00:25:25,030 so now I press the green flag, Pick x. 478 00:25:25,030 --> 00:25:31,290 Let's pick 50, Pick y-- 479 00:25:31,290 --> 00:25:35,530 let's pick negative 100-- 480 00:25:35,530 --> 00:25:38,170 and the cat goes to 50 and negative 100. 481 00:25:38,170 --> 00:25:42,850 If I wanted to go back to the center, Pick x or Pick 0, Pick Y or Pick 0, 482 00:25:42,850 --> 00:25:45,210 and the cat goes back to the center. 483 00:25:45,210 --> 00:25:47,620 And so you can ask multiple questions too-- each time 484 00:25:47,620 --> 00:25:51,970 Answer is whatever the answer was to the most recent question. 485 00:25:51,970 --> 00:25:54,220 And using the answers to those questions, 486 00:25:54,220 --> 00:25:57,340 we can start to do some interesting things. 487 00:25:57,340 --> 00:26:00,580 We can have the cat move around to various different places, 488 00:26:00,580 --> 00:26:04,940 and we can even use this in other blocks to control our project as well. 489 00:26:04,940 --> 00:26:07,360 Let's get rid of the cat for now and bring back 490 00:26:07,360 --> 00:26:10,870 another animal we've used before-- we'll bring back the bear. 491 00:26:10,870 --> 00:26:14,140 And the bear has a few costumes you might remember-- 492 00:26:14,140 --> 00:26:17,320 if we go into costumes for the bear, we see that there's this one costume 493 00:26:17,320 --> 00:26:19,730 called Bear A-- where the bear looks like this-- 494 00:26:19,730 --> 00:26:25,450 and there's another costume called Bear B where the bear looks like that. 495 00:26:25,450 --> 00:26:28,420 I'm going to go ahead and rename these costumes-- it turns out 496 00:26:28,420 --> 00:26:31,120 you can name costumes whatever you want to call them, 497 00:26:31,120 --> 00:26:34,090 but I'm going to call this costume 4. 498 00:26:34,090 --> 00:26:37,420 Just the number 4 because the bear is on four legs-- 499 00:26:37,420 --> 00:26:39,475 and I'll give this costume a name too, I'll 500 00:26:39,475 --> 00:26:44,260 give it the name 2 because the bear is on two legs. 501 00:26:44,260 --> 00:26:45,560 Now, why am I doing this? 502 00:26:45,560 --> 00:26:49,750 Well, it's because of what I'm about to show you, which is let's add an event-- 503 00:26:49,750 --> 00:26:53,920 when the flag is clicked, I want to ask a question, 504 00:26:53,920 --> 00:26:59,380 and the question I'm going to ask is, "how many legs? " 505 00:26:59,380 --> 00:27:04,570 And now what I'll do is I'll go into Looks and I'll say Switch Costume To. 506 00:27:04,570 --> 00:27:09,610 And notice that Switch Costume To also has an oval-shaped input next to it. 507 00:27:09,610 --> 00:27:12,820 This oval-shaped input is a dropdown where I could choose which costume I 508 00:27:12,820 --> 00:27:14,950 want the bear to use-- 509 00:27:14,950 --> 00:27:20,050 but because it's oval-shaped, I can just put my own value inside of that oval 510 00:27:20,050 --> 00:27:21,790 if I want to. 511 00:27:21,790 --> 00:27:24,250 And let's, instead of using the dropdown, 512 00:27:24,250 --> 00:27:28,250 let's just have it go to the answer. 513 00:27:28,250 --> 00:27:30,250 And so now I press the green flag-- 514 00:27:30,250 --> 00:27:36,340 the bear asks "how many legs? " Let's say four legs for the bear-- 515 00:27:36,340 --> 00:27:38,113 and now the bear's on four legs. 516 00:27:38,113 --> 00:27:40,780 If I want the bear to stand up, I'll press the green flag again, 517 00:27:40,780 --> 00:27:45,340 it says "how many legs? " I press 2, and the bear stands up. 518 00:27:45,340 --> 00:27:48,700 And, again, the reason that's happening is because when it asks how many legs, 519 00:27:48,700 --> 00:27:51,590 I type in something like 2 as my answer. 520 00:27:51,590 --> 00:27:55,120 And so this block runs, we're going to Switch Costume To-- 521 00:27:55,120 --> 00:27:57,070 in this case, 2-- 522 00:27:57,070 --> 00:28:00,160 and because I named my costumes after those answers-- 523 00:28:00,160 --> 00:28:02,620 you'll remember that if I go back to the Costumes tab, 524 00:28:02,620 --> 00:28:05,170 I had given those costumes particular names. 525 00:28:05,170 --> 00:28:08,230 I called one of the costumes 4, for the four leg version, 526 00:28:08,230 --> 00:28:11,410 and one of the costumes 2 for the two leg version. 527 00:28:11,410 --> 00:28:15,610 Well then I can use those blocks to control how many legs the bear is 528 00:28:15,610 --> 00:28:17,170 ultimately going to be standing on. 529 00:28:17,170 --> 00:28:18,970 And that works for costumes, and it works 530 00:28:18,970 --> 00:28:22,460 for other parts of Scratch's interface, like backdrops, for example. 531 00:28:22,460 --> 00:28:23,710 So we could try that out too-- 532 00:28:23,710 --> 00:28:26,560 I'll go ahead and get rid of the-- 533 00:28:26,560 --> 00:28:30,200 we'll keep the bear for now, but I'll get rid of the question. 534 00:28:30,200 --> 00:28:34,150 Let's add some backdrops, let's add Colorful City. 535 00:28:34,150 --> 00:28:37,540 I like the look of that, the colorful city during the day, 536 00:28:37,540 --> 00:28:39,070 and let's add one more backdrop. 537 00:28:39,070 --> 00:28:45,310 Let's add the Night City, so we have a couple different backdrops 538 00:28:45,310 --> 00:28:47,800 and I'm going to change their names. 539 00:28:47,800 --> 00:28:51,490 This Colorful city, I'm going to call it Day-- 540 00:28:51,490 --> 00:28:55,450 and again, just up at the top here, I can change the name of this backdrop. 541 00:28:55,450 --> 00:29:00,100 And for the Night City, I'm going to call it Night. 542 00:29:00,100 --> 00:29:07,540 So I have one backdrop called Day and one backdrop that I've called Night-- 543 00:29:07,540 --> 00:29:10,270 and let's go back into the code. 544 00:29:10,270 --> 00:29:12,460 And now for the bear-- 545 00:29:12,460 --> 00:29:15,460 when the flag is clicked, I want the bear to ask a question. 546 00:29:15,460 --> 00:29:19,250 547 00:29:19,250 --> 00:29:22,080 "What time? " Like, what time of day is it? 548 00:29:22,080 --> 00:29:28,752 And let's go ahead and switch the backdrop to whatever the answer is. 549 00:29:28,752 --> 00:29:30,710 So the bear is going to ask me what time of day 550 00:29:30,710 --> 00:29:34,280 do I want-- if I say day, that's one possible answer, if I say night, that's 551 00:29:34,280 --> 00:29:35,672 another possible answer. 552 00:29:35,672 --> 00:29:36,380 So we'll try it-- 553 00:29:36,380 --> 00:29:39,380 I'll press the flag, "what time? " I'll say night-- 554 00:29:39,380 --> 00:29:43,130 I'll press Return, and now it's nighttime. 555 00:29:43,130 --> 00:29:44,480 I'll try it again-- 556 00:29:44,480 --> 00:29:49,760 "what time of day? " I'll say day, and now it's daytime. 557 00:29:49,760 --> 00:29:52,610 And so using this ability now to have Return values, 558 00:29:52,610 --> 00:29:55,520 we can create much more interactive and much more exciting 559 00:29:55,520 --> 00:29:58,280 programs by letting the user tell us something 560 00:29:58,280 --> 00:30:00,080 and using that answer in the project. 561 00:30:00,080 --> 00:30:02,780 Letting them type in their name and responding to them by name, 562 00:30:02,780 --> 00:30:05,540 or letting them type in what backdrop or costume they want, 563 00:30:05,540 --> 00:30:07,670 or letting them type in how they want to control-- 564 00:30:07,670 --> 00:30:11,150 how sprite moves, or where it's pointing, or in what direction 565 00:30:11,150 --> 00:30:12,420 it's going for example. 566 00:30:12,420 --> 00:30:14,570 And so you give the user a lot more control 567 00:30:14,570 --> 00:30:18,677 over what's happening just by taking advantage of these values. 568 00:30:18,677 --> 00:30:21,510 That's it for an Introduction to Programming with Scratch for today. 569 00:30:21,510 --> 00:30:23,240 Next time, we'll continue this discussion 570 00:30:23,240 --> 00:30:25,130 and to take a look at some other features 571 00:30:25,130 --> 00:30:28,780 that we get in this world of programming with Scratch. 572 00:30:28,780 --> 00:30:30,000