1 00:00:00,000 --> 00:00:04,455 [MUSIC PLAYING] 2 00:00:04,455 --> 00:00:17,033 3 00:00:17,033 --> 00:00:19,200 BRIAN YU: Welcome back, everyone, to an introduction 4 00:00:19,200 --> 00:00:20,520 to programming with Scratch. 5 00:00:20,520 --> 00:00:24,030 And last time, we took a look at values, pieces of information 6 00:00:24,030 --> 00:00:26,460 that are stored inside of our Scratch programs 7 00:00:26,460 --> 00:00:29,190 that we could use inside of those programs. 8 00:00:29,190 --> 00:00:31,950 Today we'll take that idea one step further and take a look 9 00:00:31,950 --> 00:00:35,280 at how we can use information inside of our Scratch programs 10 00:00:35,280 --> 00:00:39,360 to make decisions by asking questions, and then deciding what to do 11 00:00:39,360 --> 00:00:42,000 based on the answer to those questions. 12 00:00:42,000 --> 00:00:45,300 And people do this type of thing all the time, asking a question 13 00:00:45,300 --> 00:00:46,560 and then making a decision. 14 00:00:46,560 --> 00:00:48,977 When you're deciding when you're trying to leave the home, 15 00:00:48,977 --> 00:00:51,270 you might look outside and ask, is it cold outside? 16 00:00:51,270 --> 00:00:53,353 And if it's cold outside, you might wear a jacket. 17 00:00:53,353 --> 00:00:55,090 Or you might ask, is it raining today? 18 00:00:55,090 --> 00:00:56,923 And if it's raining, well, then you're going 19 00:00:56,923 --> 00:00:59,710 to take the action of bringing an umbrella with you, for example. 20 00:00:59,710 --> 00:01:03,170 And you can think of this type of logic as having two parts. 21 00:01:03,170 --> 00:01:04,800 There's a question that you're asking. 22 00:01:04,800 --> 00:01:05,850 Is it raining outside? 23 00:01:05,850 --> 00:01:07,020 Is it cold outside? 24 00:01:07,020 --> 00:01:09,450 And then there's the logic, the decision that you make 25 00:01:09,450 --> 00:01:11,830 based on the answer to that question. 26 00:01:11,830 --> 00:01:13,320 And computers do the same thing. 27 00:01:13,320 --> 00:01:16,710 Computers ask questions like, is the computer low on battery? 28 00:01:16,710 --> 00:01:18,480 Is the computer connected to the internet? 29 00:01:18,480 --> 00:01:20,920 And based on the answers to those questions, 30 00:01:20,920 --> 00:01:22,380 the computer makes a decision. 31 00:01:22,380 --> 00:01:25,950 And today we'll try to do exactly that sort of thing inside of our Scratch 32 00:01:25,950 --> 00:01:28,290 programs as well-- asking a question and then 33 00:01:28,290 --> 00:01:32,200 making a decision based on the answer to that question. 34 00:01:32,200 --> 00:01:35,760 So let's go ahead and open up Scratch, and we see the familiar Scratch cat 35 00:01:35,760 --> 00:01:36,690 here. 36 00:01:36,690 --> 00:01:41,490 And let's make something happen whenever the Space key is pressed. 37 00:01:41,490 --> 00:01:42,580 That's one of our events. 38 00:01:42,580 --> 00:01:47,640 So I'll drag that when Space key press event out into my code editor. 39 00:01:47,640 --> 00:01:50,940 And when the Space is pressed, let's play a sound. 40 00:01:50,940 --> 00:01:53,330 And we'll play the meow sound. 41 00:01:53,330 --> 00:01:55,080 So now, every time I press the Space key-- 42 00:01:55,080 --> 00:01:57,540 [MEOWING] 43 00:01:57,540 --> 00:01:59,790 You'll hear the cat meow. 44 00:01:59,790 --> 00:02:02,350 But now, to make this a little bit more interesting, 45 00:02:02,350 --> 00:02:06,120 let's introduce a new block-- which you can find under the Control section 46 00:02:06,120 --> 00:02:07,380 of the blocks-- 47 00:02:07,380 --> 00:02:10,169 and that's this if block. 48 00:02:10,169 --> 00:02:12,300 And what you'll notice in this if block is 49 00:02:12,300 --> 00:02:16,330 that there are two places where we can add additional blocks into this if 50 00:02:16,330 --> 00:02:16,980 block. 51 00:02:16,980 --> 00:02:22,680 You'll notice that next to the word if is a little hexagonal shaped region 52 00:02:22,680 --> 00:02:24,502 where I could drop a block in there. 53 00:02:24,502 --> 00:02:25,960 And we'll do that in just a moment. 54 00:02:25,960 --> 00:02:29,490 And this hexagon is going to represent the question that we're asking. 55 00:02:29,490 --> 00:02:32,640 We're going to ask a question inside of our Scratch program. 56 00:02:32,640 --> 00:02:34,140 It's going to be a yes/no question. 57 00:02:34,140 --> 00:02:36,630 Is the answer to the question yes or no? 58 00:02:36,630 --> 00:02:40,410 Or equivalently, is this question true or false? 59 00:02:40,410 --> 00:02:42,390 And based on the answer to that question, 60 00:02:42,390 --> 00:02:44,880 we might run some additional blocks that are 61 00:02:44,880 --> 00:02:48,630 contained inside of this if block here. 62 00:02:48,630 --> 00:02:50,820 You see this block has a top and a bottom, 63 00:02:50,820 --> 00:02:54,510 and what that's going to allow us to do is enclose other blocks 64 00:02:54,510 --> 00:02:58,190 inside of this if block right here. 65 00:02:58,190 --> 00:02:59,940 So let's take a look at an example of that 66 00:02:59,940 --> 00:03:04,350 and see how we can fill in those two different parts of the if block. 67 00:03:04,350 --> 00:03:07,080 The first thing we need is a question, and for that, we 68 00:03:07,080 --> 00:03:10,230 can go down into the Sensing section of blocks. 69 00:03:10,230 --> 00:03:14,350 And you'll notice there are a couple of blocks that have this hexagon shape. 70 00:03:14,350 --> 00:03:16,050 These are questions that we can ask. 71 00:03:16,050 --> 00:03:20,040 In computer science, we often call these questions Boolean expressions. 72 00:03:20,040 --> 00:03:24,180 A Boolean expression is a fancy way of saying anything that is either true-- 73 00:03:24,180 --> 00:03:27,690 meaning yes-- or false, meaning no. 74 00:03:27,690 --> 00:03:30,660 And the very first one here in the Sensing category 75 00:03:30,660 --> 00:03:34,650 is a Boolean expression called touching mouse pointer. 76 00:03:34,650 --> 00:03:38,258 So I'll go ahead and drag that into the hexagon here, in the if statement. 77 00:03:38,258 --> 00:03:40,050 And you'll notice that it snaps into place. 78 00:03:40,050 --> 00:03:42,510 It fits right inside of that if statement, 79 00:03:42,510 --> 00:03:45,760 which grows to fit the size of the hexagon block. 80 00:03:45,760 --> 00:03:49,240 And then I'll take the play sound meow until done block, 81 00:03:49,240 --> 00:03:54,850 and drag it inside of the if statement, and connect all of that 82 00:03:54,850 --> 00:03:58,300 to the event when the Space key is pressed. 83 00:03:58,300 --> 00:03:59,920 So now the logic is this. 84 00:03:59,920 --> 00:04:03,760 When I press the space key, the if block is going to ask that question. 85 00:04:03,760 --> 00:04:07,880 Is the cat touching the mouse pointer, the cursor on the screen? 86 00:04:07,880 --> 00:04:10,360 And if the answer is yes, then we're going 87 00:04:10,360 --> 00:04:12,040 to play the sound meow until done. 88 00:04:12,040 --> 00:04:16,779 But that's only going to happen if this condition is true, if we are actually 89 00:04:16,779 --> 00:04:18,430 touching the mouse pointer. 90 00:04:18,430 --> 00:04:21,339 So if I put my mouse pointer somewhere other than the cat 91 00:04:21,339 --> 00:04:26,620 and I press the Spacebar, you'll notice that I don't hear anything. 92 00:04:26,620 --> 00:04:29,880 But if I move my cursor over the cat and now press the Spacebar-- 93 00:04:29,880 --> 00:04:32,772 [MEOWING] 94 00:04:32,772 --> 00:04:34,220 95 00:04:34,220 --> 00:04:39,320 Now, every time I press the Spacebar, you do, in fact, hear the cat meow. 96 00:04:39,320 --> 00:04:43,730 So our programs using these conditions now have the ability to make decisions, 97 00:04:43,730 --> 00:04:47,730 to ask a question and then make a decision based on the answer. 98 00:04:47,730 --> 00:04:50,090 And this touching mouse pointer block can 99 00:04:50,090 --> 00:04:53,240 be used to check if the sprite is touching the mouse pointer, 100 00:04:53,240 --> 00:04:56,120 but also if it's touching another sprite, for example. 101 00:04:56,120 --> 00:04:58,820 Let's say the cat is playing with a balloon. 102 00:04:58,820 --> 00:05:00,410 I can drag a balloon out. 103 00:05:00,410 --> 00:05:02,360 So we've got the cat and the balloon. 104 00:05:02,360 --> 00:05:07,460 And I'll say, for the cat, now, if you're touching the balloon, 105 00:05:07,460 --> 00:05:09,170 then play the meow sound. 106 00:05:09,170 --> 00:05:14,505 So right now I press the Spacebar, and nothing happens, 107 00:05:14,505 --> 00:05:16,880 but if I move the cat so that it's touching the balloon-- 108 00:05:16,880 --> 00:05:18,680 [MEOWING] 109 00:05:18,680 --> 00:05:23,230 Well, now we're able to detect that. 110 00:05:23,230 --> 00:05:26,090 We're able to sense that the cat is touching the balloon, 111 00:05:26,090 --> 00:05:29,350 and because of that we're able to make some decisions. 112 00:05:29,350 --> 00:05:31,630 And these sensing blocks give you the ability 113 00:05:31,630 --> 00:05:35,440 to allow your sprites to sense the things around it, figure out how close 114 00:05:35,440 --> 00:05:37,960 or how far away are other rights [INAUDIBLE] the cursor, 115 00:05:37,960 --> 00:05:41,290 figure out what it's touching, whether it's touching a particular sprite 116 00:05:41,290 --> 00:05:44,020 or even touching a particular color. 117 00:05:44,020 --> 00:05:47,680 This block here lets you check if the sprite is touching something 118 00:05:47,680 --> 00:05:50,050 that is a particular color, and you can use 119 00:05:50,050 --> 00:05:54,178 that to build some interesting interfaces as well. 120 00:05:54,178 --> 00:05:55,220 So let's give that a try. 121 00:05:55,220 --> 00:05:59,440 I'll get rid of the balloon for now, and let's add a backdrop 122 00:05:59,440 --> 00:06:01,150 for our cat to play around in. 123 00:06:01,150 --> 00:06:05,060 And I want to try the winter backdrop here. 124 00:06:05,060 --> 00:06:06,580 So you've got a winter backdrop. 125 00:06:06,580 --> 00:06:08,710 And now the code I'm going to write is this. 126 00:06:08,710 --> 00:06:10,900 We're no longer going to respond to the Space key, 127 00:06:10,900 --> 00:06:14,360 so I'll delete that by dragging it off. 128 00:06:14,360 --> 00:06:18,110 But now, when the right arrow key is pressed, 129 00:06:18,110 --> 00:06:20,000 I'd like the cat to move to the right. 130 00:06:20,000 --> 00:06:21,500 This is something we've seen before. 131 00:06:21,500 --> 00:06:24,470 Moving is controlled by a motion block, and we 132 00:06:24,470 --> 00:06:27,290 are going to change the x value by 10. 133 00:06:27,290 --> 00:06:30,050 Remember, the x is, how far to the left or to the right 134 00:06:30,050 --> 00:06:32,030 is this particular sprite? 135 00:06:32,030 --> 00:06:35,600 So when the right arrow's pressed, we're going to change the x value by 10, 136 00:06:35,600 --> 00:06:39,200 but now what I'd like to do is get the cat to detect somehow 137 00:06:39,200 --> 00:06:41,070 when it's touching one of the trees. 138 00:06:41,070 --> 00:06:42,470 There's a tree off to the right. 139 00:06:42,470 --> 00:06:43,762 There's a tree off to the left. 140 00:06:43,762 --> 00:06:46,850 If the cat is ever touching a tree, I'd like the cat to know, 141 00:06:46,850 --> 00:06:48,360 so we can report as much. 142 00:06:48,360 --> 00:06:51,200 It can say that it found a tree, for instance. 143 00:06:51,200 --> 00:06:52,728 How could we do that? 144 00:06:52,728 --> 00:06:54,020 Well, the tree is not a sprite. 145 00:06:54,020 --> 00:06:57,120 It's not one of these sprites that I see down below. 146 00:06:57,120 --> 00:06:58,520 It's just part of the backdrop. 147 00:06:58,520 --> 00:06:59,850 It's just there. 148 00:06:59,850 --> 00:07:02,360 And so if I want to detect it, I can detect it 149 00:07:02,360 --> 00:07:04,790 by looking for a particular color. 150 00:07:04,790 --> 00:07:08,100 So I might say, if-- 151 00:07:08,100 --> 00:07:09,960 and then going to Sensing-- 152 00:07:09,960 --> 00:07:12,290 touching color. 153 00:07:12,290 --> 00:07:15,070 And if I click on this little color well here in this oval, 154 00:07:15,070 --> 00:07:18,960 I can control what color I'd like to check to see if I'm touching. 155 00:07:18,960 --> 00:07:22,210 And I could try to come up with a green that looks like the green of the tree, 156 00:07:22,210 --> 00:07:24,550 but it'll be difficult for me to get it exactly. 157 00:07:24,550 --> 00:07:27,580 And for that reason, there's a great tool down below. 158 00:07:27,580 --> 00:07:30,880 If I click on this eyedropper button, that 159 00:07:30,880 --> 00:07:32,800 lets me pick a color from the stage. 160 00:07:32,800 --> 00:07:35,590 You'll notice I can drag my cursor over the stage. 161 00:07:35,590 --> 00:07:37,660 It's picking out individual colors. 162 00:07:37,660 --> 00:07:41,710 And I can say, I want you to detect this color right here, this green 163 00:07:41,710 --> 00:07:43,880 that my cursor's hovering over now. 164 00:07:43,880 --> 00:07:45,950 And you'll notice that, when I click there, 165 00:07:45,950 --> 00:07:48,040 now the colors automatically update. 166 00:07:48,040 --> 00:07:51,070 Now my cat is going to be checking if it's ever touching 167 00:07:51,070 --> 00:07:54,050 that green that makes up those trees. 168 00:07:54,050 --> 00:07:56,440 And if it is touching the green that makes up the trees, 169 00:07:56,440 --> 00:08:00,490 well, then let's go ahead and have the cat say something. 170 00:08:00,490 --> 00:08:05,300 And the cat's going to say, I found a tree. 171 00:08:05,300 --> 00:08:09,970 So now the cat can move to the right every time I press the right key. 172 00:08:09,970 --> 00:08:10,900 And it just moves. 173 00:08:10,900 --> 00:08:12,012 That's all it's doing. 174 00:08:12,012 --> 00:08:12,970 But it's also checking. 175 00:08:12,970 --> 00:08:16,802 It's asking that question, is the cat touching the green? 176 00:08:16,802 --> 00:08:19,510 And it's not touching the green, so nothing's happening just yet. 177 00:08:19,510 --> 00:08:23,110 Every time I press the arrow key, we're just changing the x value. 178 00:08:23,110 --> 00:08:24,130 But watch what happens. 179 00:08:24,130 --> 00:08:28,030 Eventually-- and it'll probably happen right there-- 180 00:08:28,030 --> 00:08:33,530 the cat touches the green in the tree, and the cat says, I found a tree. 181 00:08:33,530 --> 00:08:36,652 So these sensing blocks allow us to let our sprites 182 00:08:36,652 --> 00:08:38,860 be a little more intelligent about what's around it-- 183 00:08:38,860 --> 00:08:42,020 what's in the backdrop, what colors does it happen to be touching, 184 00:08:42,020 --> 00:08:44,360 and what spritz does it happen to be touching. 185 00:08:44,360 --> 00:08:49,190 And we can use that to create some interesting programs as well. 186 00:08:49,190 --> 00:08:52,243 But let's now revisit one of the programs that we already made 187 00:08:52,243 --> 00:08:54,160 and see if we can make it a little better now. 188 00:08:54,160 --> 00:08:57,040 I'll go ahead and delete the cat and change the backdrop. 189 00:08:57,040 --> 00:09:00,970 We'll go back to just the plain white backdrop. 190 00:09:00,970 --> 00:09:03,520 And let's bring back the balloon. 191 00:09:03,520 --> 00:09:06,280 You might remember from when we were working with the balloon 192 00:09:06,280 --> 00:09:09,160 a little bit earlier that we were making the balloon bigger. 193 00:09:09,160 --> 00:09:11,368 Every time we blew, for example, into the microphone, 194 00:09:11,368 --> 00:09:13,577 the balloon was getting bigger and bigger and bigger. 195 00:09:13,577 --> 00:09:15,830 In reality, you can't make a balloon bigger forever. 196 00:09:15,830 --> 00:09:18,910 Eventually, that balloon is going to pop, and so let's 197 00:09:18,910 --> 00:09:20,620 get this balloon to eventually pop. 198 00:09:20,620 --> 00:09:24,280 I'll go ahead and center the balloon by changing the x and the y 199 00:09:24,280 --> 00:09:26,450 values both to 0. 200 00:09:26,450 --> 00:09:30,920 And now I'll have the balloon respond to me pressing the Space key. 201 00:09:30,920 --> 00:09:34,340 The Space key is how I'm going to inflate this balloon. 202 00:09:34,340 --> 00:09:43,020 And when the Space is pressed, I would like to change the size by 10. 203 00:09:43,020 --> 00:09:46,110 This is similar to what we had before where, whenever something happens-- 204 00:09:46,110 --> 00:09:48,623 in this case, I'm pressing the Space key-- the balloon just 205 00:09:48,623 --> 00:09:50,040 gets bigger and bigger and bigger. 206 00:09:50,040 --> 00:09:52,590 And you can see the size down below grow. 207 00:09:52,590 --> 00:09:53,860 It's 170 now. 208 00:09:53,860 --> 00:09:54,880 Now it's 180. 209 00:09:54,880 --> 00:09:55,780 Now it's 190. 210 00:09:55,780 --> 00:09:57,720 Now it's 200, for example. 211 00:09:57,720 --> 00:10:00,180 And this maybe feels big enough. 212 00:10:00,180 --> 00:10:05,510 Once it gets to size 200, then I want to have the balloon pop, for example. 213 00:10:05,510 --> 00:10:10,050 So let's bring the size back to 100, back to the original size. 214 00:10:10,050 --> 00:10:11,820 I can ask a question. 215 00:10:11,820 --> 00:10:15,312 I can go to Control and bring out an if statement. 216 00:10:15,312 --> 00:10:18,270 And this time, the question I want to ask is not whether the balloon is 217 00:10:18,270 --> 00:10:22,320 touching something-- it's whether the size is 100-- 218 00:10:22,320 --> 00:10:23,040 or 200. 219 00:10:23,040 --> 00:10:27,120 And how could I check to see if the size is 200? 220 00:10:27,120 --> 00:10:30,730 Well, down here in Operators-- we've seen a couple of operators before. 221 00:10:30,730 --> 00:10:33,930 We've seen the operators to do math, like addition, multiplication, 222 00:10:33,930 --> 00:10:35,340 subtraction, and division. 223 00:10:35,340 --> 00:10:37,740 We've seen the operator that picks a random number. 224 00:10:37,740 --> 00:10:40,530 And these were all oval-shaped operators. 225 00:10:40,530 --> 00:10:44,650 But now let's take a look at some of these hexagon-shaped operators. 226 00:10:44,650 --> 00:10:48,090 These hexagon-shaped operators are all Boolean expressions, 227 00:10:48,090 --> 00:10:52,830 things that can be either true or false, answered yes or no. 228 00:10:52,830 --> 00:10:58,800 And one of them here is whether something is equal to something else. 229 00:10:58,800 --> 00:11:02,650 So if I have two values and I want to know, are they equal to each other, 230 00:11:02,650 --> 00:11:06,300 I can use this check here-- this hexagon-shaped block-- 231 00:11:06,300 --> 00:11:09,503 to check to see if those two values are equal to each other. 232 00:11:09,503 --> 00:11:10,920 And that's what I want to do here. 233 00:11:10,920 --> 00:11:13,770 I want to take my sprite, the balloon, and check 234 00:11:13,770 --> 00:11:17,640 to see if the size is equal to 200. 235 00:11:17,640 --> 00:11:21,210 So I'll take this block, drag it into the hexagon area 236 00:11:21,210 --> 00:11:23,220 next to the if statement. 237 00:11:23,220 --> 00:11:29,340 And let me grab the size value, which is under the Looks category. 238 00:11:29,340 --> 00:11:36,790 Here's my size value, and I want to check if the size is equal to 200. 239 00:11:36,790 --> 00:11:39,730 And if the size is equal to 200, what do I want to do? 240 00:11:39,730 --> 00:11:42,630 Well, the first thing I'll have this program do is hide. 241 00:11:42,630 --> 00:11:44,550 The balloon's going to hide. 242 00:11:44,550 --> 00:11:46,710 And then, just for fun, let's go into sound 243 00:11:46,710 --> 00:11:51,092 and have the balloon play the sound pop until it's done. 244 00:11:51,092 --> 00:11:52,800 So now, what is the logic of the program? 245 00:11:52,800 --> 00:11:56,610 Well, every time I press the Space key, we're going to run this line-- 246 00:11:56,610 --> 00:11:58,260 change the size by 10. 247 00:11:58,260 --> 00:12:00,450 But we're also going to ask that question-- 248 00:12:00,450 --> 00:12:02,970 check if the size is equal to 200. 249 00:12:02,970 --> 00:12:06,990 And only if the answer to that question is yes, then we hide the balloon, 250 00:12:06,990 --> 00:12:10,240 and then we play the sound pop until it's done. 251 00:12:10,240 --> 00:12:13,020 So let's give the program a try and see what happens 252 00:12:13,020 --> 00:12:15,270 once I start to inflate this balloon. 253 00:12:15,270 --> 00:12:16,980 It's at size 100 right now. 254 00:12:16,980 --> 00:12:21,240 And remember, you can check that just by looking down below here at the size. 255 00:12:21,240 --> 00:12:22,950 And let's press the Space. 256 00:12:22,950 --> 00:12:23,880 It inflates a little. 257 00:12:23,880 --> 00:12:28,740 Its size is 110, 120, 130, 140, 150. 258 00:12:28,740 --> 00:12:31,110 And now it's at 190, and watch what happens 259 00:12:31,110 --> 00:12:33,720 the next time I try and inflate the balloon one more time, 260 00:12:33,720 --> 00:12:37,400 as by pressing the Space key. 261 00:12:37,400 --> 00:12:39,740 It goes ahead and it hides. 262 00:12:39,740 --> 00:12:42,640 And I could try that again. 263 00:12:42,640 --> 00:12:44,920 We'll go ahead and show the balloon again, 264 00:12:44,920 --> 00:12:47,840 and I can do that by using this Show block here. 265 00:12:47,840 --> 00:12:50,560 I'll just click on Show, and it will show the balloon. 266 00:12:50,560 --> 00:13:00,600 And the balloon inflates, and then it disappears with a pop. 267 00:13:00,600 --> 00:13:02,540 So that's how we can use conditions to check 268 00:13:02,540 --> 00:13:04,430 if two things are equal to each other. 269 00:13:04,430 --> 00:13:06,557 But you probably noticed down in Operators 270 00:13:06,557 --> 00:13:08,390 that we don't just have the ability to check 271 00:13:08,390 --> 00:13:10,200 if two things are equal to each other. 272 00:13:10,200 --> 00:13:14,270 We can check if one number is less than another number or greater than another 273 00:13:14,270 --> 00:13:15,660 number, for example. 274 00:13:15,660 --> 00:13:18,080 And let's give that a try. 275 00:13:18,080 --> 00:13:20,810 Instead of using the balloon, I'll bring out another sprite. 276 00:13:20,810 --> 00:13:27,380 Let's choose the duck this time. 277 00:13:27,380 --> 00:13:32,060 I'll center the duck by moving it to 0 for x and 0 for y. 278 00:13:32,060 --> 00:13:35,810 And when I press the green flag to start this program, 279 00:13:35,810 --> 00:13:38,030 the duck is going to ask a question. 280 00:13:38,030 --> 00:13:42,040 And the question might be, type a number. 281 00:13:42,040 --> 00:13:44,120 So it's asking me to type in a number. 282 00:13:44,120 --> 00:13:47,440 So now, when I press the green flag, the duck asks me to type in a number, 283 00:13:47,440 --> 00:13:48,820 and I could type in a number. 284 00:13:48,820 --> 00:13:52,750 I could type in the number 1, for example, and press Return. 285 00:13:52,750 --> 00:13:57,193 So the duck now has a number, and now we could ask questions about that number. 286 00:13:57,193 --> 00:13:59,110 So if I want to check to see if that number is 287 00:13:59,110 --> 00:14:03,220 positive or negative, for example, I could add a condition. 288 00:14:03,220 --> 00:14:10,430 I could say, if, and then take the greater than block out-- 289 00:14:10,430 --> 00:14:12,230 which is under Operators. 290 00:14:12,230 --> 00:14:14,900 And now I want to say, if the answer-- 291 00:14:14,900 --> 00:14:19,190 which is in the Sensing category-- if the answer is greater than 0, 292 00:14:19,190 --> 00:14:22,800 well, then whatever number the user typed in-- that's a positive number. 293 00:14:22,800 --> 00:14:25,640 And so we'll go into the Looks section, and let's go ahead 294 00:14:25,640 --> 00:14:30,312 and say positive for two seconds. 295 00:14:30,312 --> 00:14:33,520 So we ask the user for a number, and if the user types in a positive number-- 296 00:14:33,520 --> 00:14:35,740 something like the number 2-- 297 00:14:35,740 --> 00:14:37,260 well, the duck says positive-- 298 00:14:37,260 --> 00:14:37,760 great. 299 00:14:37,760 --> 00:14:42,070 And instead, if we typed in a negative number-- let's say negative 2-- 300 00:14:42,070 --> 00:14:43,990 the duck doesn't say anything at all. 301 00:14:43,990 --> 00:14:46,790 So we're able to check to see if their answer is positive, 302 00:14:46,790 --> 00:14:50,290 and if what the user typed in was positive-- if that's true, then 303 00:14:50,290 --> 00:14:52,780 we're going to say positive for two seconds. 304 00:14:52,780 --> 00:14:56,500 But oftentimes, we want to be able to make a decision based 305 00:14:56,500 --> 00:14:58,490 on either answer to the question. 306 00:14:58,490 --> 00:15:01,660 So far, with our if blocks, we've been asking a question, 307 00:15:01,660 --> 00:15:03,500 is the answer to this question yes? 308 00:15:03,500 --> 00:15:04,360 Is it true? 309 00:15:04,360 --> 00:15:07,240 And if so, then we're going to run some code. 310 00:15:07,240 --> 00:15:09,560 There's one block of code that we're running, 311 00:15:09,560 --> 00:15:12,880 if it's the case that the answer to the question is yes. 312 00:15:12,880 --> 00:15:15,100 But sometimes we want to handle both situations. 313 00:15:15,100 --> 00:15:17,830 If the answer to a question is yes, we want to do one thing, 314 00:15:17,830 --> 00:15:22,850 and if the answer to a question is no, then we want to do something else. 315 00:15:22,850 --> 00:15:25,160 And so let's give that a try. 316 00:15:25,160 --> 00:15:29,500 Turns out there's another block that we can use-- not just the if then block, 317 00:15:29,500 --> 00:15:34,400 but another block under Control called if then else. 318 00:15:34,400 --> 00:15:38,260 And the if then else block is structured differently than the other blocks 319 00:15:38,260 --> 00:15:39,220 we've seen so far. 320 00:15:39,220 --> 00:15:43,030 The top part looks very much like the if block we were working with before. 321 00:15:43,030 --> 00:15:47,350 There's a hexagon-shaped space for a question, and then an area beneath it 322 00:15:47,350 --> 00:15:51,280 where we could add a stack of blocks for what should happen 323 00:15:51,280 --> 00:15:53,920 if the answer to that question is yes. 324 00:15:53,920 --> 00:15:57,340 But this block now has another section called else, 325 00:15:57,340 --> 00:16:01,900 which has what appears to be an area for yet another stack of blocks. 326 00:16:01,900 --> 00:16:05,560 So inside of this block can be two separate stacks of blocks-- 327 00:16:05,560 --> 00:16:09,820 one stack of blocks that run if the answer to the question is yes, 328 00:16:09,820 --> 00:16:14,750 and another stack of blocks that run if the answer to the question is no. 329 00:16:14,750 --> 00:16:16,840 So regardless of the answer to the question, 330 00:16:16,840 --> 00:16:20,330 we're going to make a decision about which of these two blocks 331 00:16:20,330 --> 00:16:21,820 we're ultimately going to run. 332 00:16:21,820 --> 00:16:25,750 And we can use that now to handle both possibilities-- either the number 333 00:16:25,750 --> 00:16:29,570 is greater than 0 or it's not. 334 00:16:29,570 --> 00:16:32,470 And so here I'll take this answer greater than 0 block, 335 00:16:32,470 --> 00:16:34,610 drag it into this condition. 336 00:16:34,610 --> 00:16:36,730 And in that case, we're going to say positive. 337 00:16:36,730 --> 00:16:39,580 I'll get rid of this if statement, because I no longer need it. 338 00:16:39,580 --> 00:16:42,550 Now I'm going to replace it with this if else. 339 00:16:42,550 --> 00:16:46,870 If the answer is greater than 0, we're going to say positive for two seconds. 340 00:16:46,870 --> 00:16:49,840 Otherwise-- let's go into Looks-- 341 00:16:49,840 --> 00:16:55,630 let's say negative for two seconds. 342 00:16:55,630 --> 00:16:59,370 So now we're making a decision-- running some block of code either time, 343 00:16:59,370 --> 00:17:03,030 but making a decision about which block of code we would like to run. 344 00:17:03,030 --> 00:17:04,290 I'll start the program. 345 00:17:04,290 --> 00:17:05,609 It's asking me for a number. 346 00:17:05,609 --> 00:17:08,550 I'll type in a positive number, like the number 2. 347 00:17:08,550 --> 00:17:10,980 And the duck says positive. 348 00:17:10,980 --> 00:17:12,170 We'll try it again. 349 00:17:12,170 --> 00:17:13,170 Asking me for a number-- 350 00:17:13,170 --> 00:17:15,300 I'll type in a negative number-- negative 2. 351 00:17:15,300 --> 00:17:17,260 And the duck says negative. 352 00:17:17,260 --> 00:17:20,290 So if the answer to the question is yes, we run one block. 353 00:17:20,290 --> 00:17:22,829 Otherwise, we run another block. 354 00:17:22,829 --> 00:17:24,780 And now, there's a slight bug in this program. 355 00:17:24,780 --> 00:17:27,089 You might have noticed that it does well for positive numbers 356 00:17:27,089 --> 00:17:29,280 and it does well for negative numbers, but there 357 00:17:29,280 --> 00:17:33,240 is one number that's not really positive and it's not really negative, 358 00:17:33,240 --> 00:17:34,710 and that's a 0. 359 00:17:34,710 --> 00:17:39,210 If I type in 0 in press Return, the duck says negative. 360 00:17:39,210 --> 00:17:40,180 Now, why is that? 361 00:17:40,180 --> 00:17:43,230 Well, it's asking, is the answer greater than 0? 362 00:17:43,230 --> 00:17:44,560 Is 0 greater than 0? 363 00:17:44,560 --> 00:17:45,060 Well, no. 364 00:17:45,060 --> 00:17:47,280 0 is not greater than 0. 365 00:17:47,280 --> 00:17:49,560 So instead of running the if block, we instead 366 00:17:49,560 --> 00:17:54,793 run this else block, where we just say negative every time. 367 00:17:54,793 --> 00:17:56,460 And that's maybe not quite what we want. 368 00:17:56,460 --> 00:18:00,300 What I probably want is to ask yet another question-- to ask again, 369 00:18:00,300 --> 00:18:02,580 is the answer less than 0? 370 00:18:02,580 --> 00:18:03,900 If so, then it's negative. 371 00:18:03,900 --> 00:18:07,050 And otherwise, if it's not more than 0 and it's not less than 0, 372 00:18:07,050 --> 00:18:09,750 then it must just be 0. 373 00:18:09,750 --> 00:18:15,390 And to do that, I could add yet another condition inside of this stack here. 374 00:18:15,390 --> 00:18:19,210 I can add anything if else inside of another if else. 375 00:18:19,210 --> 00:18:24,450 And to do that, I'll take another if else, drag it here underneath the else. 376 00:18:24,450 --> 00:18:26,280 And so now, if the number's not positive, 377 00:18:26,280 --> 00:18:29,940 I can ask a second question-- ask yet another question. 378 00:18:29,940 --> 00:18:35,520 Now the question I want to ask is, is my answer-- 379 00:18:35,520 --> 00:18:37,710 the answer's in the Sensing category-- 380 00:18:37,710 --> 00:18:40,320 is the answer to less than 0? 381 00:18:40,320 --> 00:18:44,460 If the answer is less than 0, then I want to say negative for two seconds, 382 00:18:44,460 --> 00:18:46,020 but otherwise-- 383 00:18:46,020 --> 00:18:47,860 let's go into Looks-- 384 00:18:47,860 --> 00:18:51,810 I'm just going to say 0. 385 00:18:51,810 --> 00:18:54,690 So this is starting to get more complex I have blocks inside 386 00:18:54,690 --> 00:18:56,460 of blocks inside of other blocks. 387 00:18:56,460 --> 00:19:00,010 And the way to read this now is, what happens if the user types in the number 388 00:19:00,010 --> 00:19:00,690 0? 389 00:19:00,690 --> 00:19:02,970 Well, we start by asking this question here-- 390 00:19:02,970 --> 00:19:05,850 is the answer 0 greater than 0? 391 00:19:05,850 --> 00:19:09,900 No, 0 is not greater than 0, so we ignore the if block 392 00:19:09,900 --> 00:19:12,150 and we just look to the else section. 393 00:19:12,150 --> 00:19:13,710 And now we ask another question. 394 00:19:13,710 --> 00:19:17,070 Is the answer 0 less than 0? 395 00:19:17,070 --> 00:19:18,940 Well, no, that's not true either. 396 00:19:18,940 --> 00:19:21,850 So we don't run this block, and we instead go to the else, 397 00:19:21,850 --> 00:19:26,340 and we run this block, which says, say 0 for two seconds. 398 00:19:26,340 --> 00:19:29,170 And that's exactly the behavior we want for the duck. 399 00:19:29,170 --> 00:19:33,310 So we can verify now that it works by pressing the green flag. 400 00:19:33,310 --> 00:19:36,450 And if I type in 0, the duck reports that I 401 00:19:36,450 --> 00:19:38,490 did, in fact, type in the number 0. 402 00:19:38,490 --> 00:19:42,880 If I instead typed a positive number, the duck's is going to say positive. 403 00:19:42,880 --> 00:19:45,870 And if I type the negative number, well, then the duck 404 00:19:45,870 --> 00:19:48,730 is going to say negative instead. 405 00:19:48,730 --> 00:19:51,960 And so using that, I have the ability to ask multiple questions 406 00:19:51,960 --> 00:19:56,050 and make decisions based on the answers to those questions. 407 00:19:56,050 --> 00:19:59,610 So let's use this ability now to build some interesting games that 408 00:19:59,610 --> 00:20:02,870 use our ability to ask questions and make decisions. 409 00:20:02,870 --> 00:20:05,100 And for that, I'll bring back one of our animals. 410 00:20:05,100 --> 00:20:09,180 We'll go to Animals, and let's bring back the hedgehog. 411 00:20:09,180 --> 00:20:12,840 And what I'd like for the hedgehog to do is to race across the stage-- 412 00:20:12,840 --> 00:20:15,300 start at one point in the stage, try and get all the way 413 00:20:15,300 --> 00:20:19,480 to the right edge of the stage, and see how quickly we can do that. 414 00:20:19,480 --> 00:20:22,120 So how would I go about creating this game? 415 00:20:22,120 --> 00:20:25,410 Well, when the green flag is clicked, when I start the program, 416 00:20:25,410 --> 00:20:30,180 I would like the hedgehog to move to the left side of the stage 417 00:20:30,180 --> 00:20:33,790 as a place to begin this particular race. 418 00:20:33,790 --> 00:20:36,860 So we'll have it go to a particular location. 419 00:20:36,860 --> 00:20:37,860 And this is about right. 420 00:20:37,860 --> 00:20:41,097 Maybe I'll say negative 150 and negative 25 for y. 421 00:20:41,097 --> 00:20:43,930 And I could play around with that to figure out exactly what I want, 422 00:20:43,930 --> 00:20:47,250 but I'm just choosing nice looking numbers for now. 423 00:20:47,250 --> 00:20:49,050 And then every time-- 424 00:20:49,050 --> 00:20:52,150 not the Space key, but maybe the right key is pressed, 425 00:20:52,150 --> 00:20:55,050 I would like for the hedgehog to move a little bit closer 426 00:20:55,050 --> 00:20:57,600 towards the edge of the stage. 427 00:20:57,600 --> 00:21:02,560 So I could have the hedgehog move 10 steps, for example. 428 00:21:02,560 --> 00:21:05,340 And what I would like for the hedgehog to do 429 00:21:05,340 --> 00:21:08,757 is, once it reaches the edge of the stage, 430 00:21:08,757 --> 00:21:10,840 it should report back to me, how long did it take? 431 00:21:10,840 --> 00:21:12,990 How many seconds did it take for the hedgehog 432 00:21:12,990 --> 00:21:16,630 to get from one side of the stage to the other? 433 00:21:16,630 --> 00:21:19,740 And so for that, I can ask a question. 434 00:21:19,740 --> 00:21:20,910 We'll go into Control. 435 00:21:20,910 --> 00:21:24,480 I'll drag an if block out, and the question I want to ask-- 436 00:21:24,480 --> 00:21:26,400 which will be located under Sensing-- 437 00:21:26,400 --> 00:21:29,550 is not whether the hedgehog is touching the mouse pointer, 438 00:21:29,550 --> 00:21:31,740 but if the hedgehog is touching the edge-- 439 00:21:31,740 --> 00:21:33,382 meaning the edge of the stage. 440 00:21:33,382 --> 00:21:36,090 And if the hedgehog is touching the edge of the stage, what would 441 00:21:36,090 --> 00:21:38,010 I like for the hedgehog to do? 442 00:21:38,010 --> 00:21:40,650 Well, I want the hedgehog to say something. 443 00:21:40,650 --> 00:21:42,630 And what do I wanted to say? 444 00:21:42,630 --> 00:21:47,070 Well, I want the hedgehog to say whatever this timer value is. 445 00:21:47,070 --> 00:21:49,200 Remember, the timer is a value that keeps 446 00:21:49,200 --> 00:21:53,880 track of how many seconds have passed since the beginning of my program. 447 00:21:53,880 --> 00:21:56,700 And I could have it say just the timer, but I'm actually 448 00:21:56,700 --> 00:21:58,200 going to use an operator first. 449 00:21:58,200 --> 00:22:04,200 I'm going to have us first round the timer, and then say that result. Why 450 00:22:04,200 --> 00:22:04,950 am I doing that? 451 00:22:04,950 --> 00:22:07,575 Well, the timer normally has something after the decimal point. 452 00:22:07,575 --> 00:22:10,148 Maybe like 5.28 seconds have passed or something like that, 453 00:22:10,148 --> 00:22:12,690 and I don't really care about what's after the decimal point. 454 00:22:12,690 --> 00:22:16,090 I just want to know, has it been five seconds, or six, or seven seconds, 455 00:22:16,090 --> 00:22:17,440 for example? 456 00:22:17,440 --> 00:22:21,460 So now we're going to move the hedgehog every time I press the right arrow key, 457 00:22:21,460 --> 00:22:23,430 and if we're touching the edge, we're going 458 00:22:23,430 --> 00:22:27,850 to say whatever the value of the timer is for two seconds. 459 00:22:27,850 --> 00:22:30,430 So let's give that a try. 460 00:22:30,430 --> 00:22:32,190 We'll start the program, and every time I 461 00:22:32,190 --> 00:22:35,460 press the right arrow, the hedgehog moves a little bit. 462 00:22:35,460 --> 00:22:41,080 And when it reaches the edge, it's going to report how many seconds it took. 463 00:22:41,080 --> 00:22:44,050 In this case, it took nine seconds for the hedgehog 464 00:22:44,050 --> 00:22:47,980 to get all the way to the rightmost edge of the stage. 465 00:22:47,980 --> 00:22:51,478 But we can keep asking more questions here, adding more blocks to the program 466 00:22:51,478 --> 00:22:53,020 to make it a little more interesting. 467 00:22:53,020 --> 00:22:57,850 I'll get rid of this, say, for now, and instead replace it with an if else-- 468 00:22:57,850 --> 00:23:00,610 an opportunity to ask another question. 469 00:23:00,610 --> 00:23:03,880 And this time the question I want to ask is this. 470 00:23:03,880 --> 00:23:09,140 Under Operators, I'm going to take the less than block out, and I want to ask, 471 00:23:09,140 --> 00:23:13,170 is the timer less than five? 472 00:23:13,170 --> 00:23:15,870 Remember, this question is only ask one time at the edge. 473 00:23:15,870 --> 00:23:19,480 Once the hedgehog has reached the edge of the stage, we're going to ask, 474 00:23:19,480 --> 00:23:21,840 has it been fewer than five seconds? 475 00:23:21,840 --> 00:23:25,860 And if so, that was pretty fast, so let's go ahead and have the hedgehog 476 00:23:25,860 --> 00:23:30,210 say fast for two seconds. 477 00:23:30,210 --> 00:23:35,587 And otherwise, if the timer was not less than five, then 478 00:23:35,587 --> 00:23:37,920 we were going kind of slowly, so we'll have the hedgehog 479 00:23:37,920 --> 00:23:41,040 say slow for two seconds instead. 480 00:23:41,040 --> 00:23:43,760 So now, if I press the green flag and move quickly-- 481 00:23:43,760 --> 00:23:47,000 very quickly try and move the hedgehog across the stage, 482 00:23:47,000 --> 00:23:48,500 well, then the hedgehog says fast. 483 00:23:48,500 --> 00:23:51,600 I managed to make it across in fewer than five seconds. 484 00:23:51,600 --> 00:23:53,030 But if I'm going more slowly-- 485 00:23:53,030 --> 00:23:59,520 I'll try it again, and more slowly press the right arrow key. 486 00:23:59,520 --> 00:24:03,840 Well, then it's going to take a little bit longer, and at the end, 487 00:24:03,840 --> 00:24:06,600 the hedgehog does report that I was slow, that I was not 488 00:24:06,600 --> 00:24:08,760 very fast at moving across. 489 00:24:08,760 --> 00:24:10,470 So that's one possible game you could try 490 00:24:10,470 --> 00:24:13,380 to build by asking questions-- questions about whether we're touching 491 00:24:13,380 --> 00:24:17,730 the edge, questions about whether the timer is a particular value-- less 492 00:24:17,730 --> 00:24:19,870 than a particular value, for example. 493 00:24:19,870 --> 00:24:23,850 And let's try one more example of a game we could build with the hedgehog. 494 00:24:23,850 --> 00:24:26,460 Go ahead and get rid of these blocks for now. 495 00:24:26,460 --> 00:24:29,790 Let's try and build a maze for the hedgehog to try and navigate around, 496 00:24:29,790 --> 00:24:33,550 where you're not supposed to hit any of the walls of the maze, for example. 497 00:24:33,550 --> 00:24:36,120 And I could do that by changing the backdrop. 498 00:24:36,120 --> 00:24:39,360 Let's use the backdrop to build a maze for our hedgehog. 499 00:24:39,360 --> 00:24:44,430 I want the walls to be red maybe, and I'll 500 00:24:44,430 --> 00:24:46,650 go ahead and click on this line tool that's going 501 00:24:46,650 --> 00:24:50,640 to let me draw lines on the stage. 502 00:24:50,640 --> 00:24:54,430 Oh, and I should really be changing the outline to make the outline red. 503 00:24:54,430 --> 00:24:57,880 So let me delete this line for now, and try it again. 504 00:24:57,880 --> 00:25:00,970 I want the outline of this to be red. 505 00:25:00,970 --> 00:25:03,430 That's going to give me some red lines. 506 00:25:03,430 --> 00:25:11,650 And I'll go ahead and just try and build a little maze for our hedgehog 507 00:25:11,650 --> 00:25:15,210 to try to navigate around. 508 00:25:15,210 --> 00:25:17,370 And that looks all right. 509 00:25:17,370 --> 00:25:19,620 I'll go back to the code. 510 00:25:19,620 --> 00:25:20,597 Here's our hedgehog. 511 00:25:20,597 --> 00:25:22,680 It's a bit big for this maze right now, so I might 512 00:25:22,680 --> 00:25:24,222 want to make it a little bit smaller. 513 00:25:24,222 --> 00:25:27,660 I can go in the Size here, change the size to-- let's try 40. 514 00:25:27,660 --> 00:25:30,150 Yeah, that's probably a good size for our hedgehog. 515 00:25:30,150 --> 00:25:32,290 And now, how do I want this maze to work? 516 00:25:32,290 --> 00:25:34,980 Well, I'll have it move via the arrow keys. 517 00:25:34,980 --> 00:25:37,950 So whenever the right arrow key is pressed, 518 00:25:37,950 --> 00:25:42,840 our hedgehog is going to change its x position by, let's say, five. 519 00:25:42,840 --> 00:25:44,730 10 is maybe a lot for this. 520 00:25:44,730 --> 00:25:47,340 So it's going to move five spaces to the right. 521 00:25:47,340 --> 00:25:48,600 And what do I want to do? 522 00:25:48,600 --> 00:25:51,750 I want to check now, is the hedgehog touching a wall? 523 00:25:51,750 --> 00:25:55,240 Because if it ends up touching a wall, that's no good. 524 00:25:55,240 --> 00:26:02,190 So I'll ask, if the hedgehog is touching a color-- 525 00:26:02,190 --> 00:26:04,230 because the walls are all red. 526 00:26:04,230 --> 00:26:06,330 So I'll grab a color using this eyedropper tool, 527 00:26:06,330 --> 00:26:08,100 grabbing it from the stage. 528 00:26:08,100 --> 00:26:11,280 Let's grab this red right here. 529 00:26:11,280 --> 00:26:14,330 So if the hedgehog is touching the color red, 530 00:26:14,330 --> 00:26:18,170 well, then I want the hedgehog to just, for now, let's say, go 531 00:26:18,170 --> 00:26:19,760 to a random position on the stage. 532 00:26:19,760 --> 00:26:23,690 It's going to somehow magically disappear and reappear somewhere else. 533 00:26:23,690 --> 00:26:26,720 We'll have it go to a random position. 534 00:26:26,720 --> 00:26:29,000 And that's what happens when I press the right arrow. 535 00:26:29,000 --> 00:26:32,330 I'm going to duplicate this whole thing by Control clicking and pressing 536 00:26:32,330 --> 00:26:36,800 Duplicate, and do the same thing for the left arrow. 537 00:26:36,800 --> 00:26:40,610 But this time, we're going to change x by negative five. 538 00:26:40,610 --> 00:26:45,020 And I also want the up and down arrows to work too, so I'll duplicate once. 539 00:26:45,020 --> 00:26:47,060 Let's do this for the up arrow. 540 00:26:47,060 --> 00:26:51,800 When the up arrow happens, I want to not change the x value by something, 541 00:26:51,800 --> 00:26:57,630 but change the y value by negative five. 542 00:26:57,630 --> 00:27:01,350 And one more arrow key-- let's duplicate this one more time and use the same 543 00:27:01,350 --> 00:27:04,300 code for the down arrow-- 544 00:27:04,300 --> 00:27:07,508 this time, changing the y by-- 545 00:27:07,508 --> 00:27:09,300 actually, here, it should be negative five, 546 00:27:09,300 --> 00:27:11,700 and for up, it should be five-- because when we're going up the, 547 00:27:11,700 --> 00:27:14,820 y value's increasing, when we're going down, the y value's decreasing. 548 00:27:14,820 --> 00:27:17,430 And I could test that out by pressing the up arrow, 549 00:27:17,430 --> 00:27:18,930 and the hedgehog moves up. 550 00:27:18,930 --> 00:27:20,440 I press the down arrow-- 551 00:27:20,440 --> 00:27:21,552 the hedgehog moves down. 552 00:27:21,552 --> 00:27:23,010 I press left-- it goes to the left. 553 00:27:23,010 --> 00:27:24,552 I press right-- it goes to the right. 554 00:27:24,552 --> 00:27:29,030 But if ever I hit-- watch what happens if I hit a red wall. 555 00:27:29,030 --> 00:27:32,250 The hedgehog magically vanishes from where it was, 556 00:27:32,250 --> 00:27:33,600 and it reappears somewhere else. 557 00:27:33,600 --> 00:27:36,740 And you could decide on your own what happens when the hedgehog hits a wall. 558 00:27:36,740 --> 00:27:37,990 Maybe it plays a sound effect. 559 00:27:37,990 --> 00:27:39,978 Maybe it does something else. 560 00:27:39,978 --> 00:27:42,020 But you could make this game however you like it. 561 00:27:42,020 --> 00:27:44,812 And here I just have a hedgehog that can navigate through the maze, 562 00:27:44,812 --> 00:27:49,000 and whenever it hits a wall, it reappears somewhere else. 563 00:27:49,000 --> 00:27:51,500 And so these conditions give you a lot of power, the ability 564 00:27:51,500 --> 00:27:55,160 to ask questions and make decisions inside of your programs 565 00:27:55,160 --> 00:27:57,530 based on the answers to those questions. 566 00:27:57,530 --> 00:28:00,430 That's it for today for an introduction to programming with Scratch. 567 00:28:00,430 --> 00:28:02,180 Next time, we'll pick up where we left off 568 00:28:02,180 --> 00:28:05,480 and see what else we can do in the world of putting together these Scratch 569 00:28:05,480 --> 00:28:06,080 blocks. 570 00:28:06,080 --> 00:28:07,990 We'll see you then. 571 00:28:07,990 --> 00:28:09,000