[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.08,0:00:03.85,Default,,0000,0000,0000,,So I've got my good friend Winston here\Nto help us out with this one. Dialogue: 0,0:00:03.85,0:00:06.42,Default,,0000,0000,0000,,And I know he already looks\Nimpossibly awesome, Dialogue: 0,0:00:06.42,0:00:08.91,Default,,0000,0000,0000,,but I think I want to change\Nhis eye size a little bit. Dialogue: 0,0:00:08.91,0:00:10.78,Default,,0000,0000,0000,,So here is where I draw his eyes. Dialogue: 0,0:00:10.78,0:00:13.34,Default,,0000,0000,0000,,You can see we set the fill color,\Nand then drop two ellipses. Dialogue: 0,0:00:13.34,0:00:15.27,Default,,0000,0000,0000,,And if I want to make\Nthis ellipse smaller, Dialogue: 0,0:00:15.27,0:00:18.01,Default,,0000,0000,0000,,I can change the width,\Nbut then I also want it to be round, Dialogue: 0,0:00:18.01,0:00:20.28,Default,,0000,0000,0000,,so I'm going to change the height\Nto be the same thing. Dialogue: 0,0:00:20.28,0:00:22.96,Default,,0000,0000,0000,,And, well I want the eyes\Nto be the same size, Dialogue: 0,0:00:22.96,0:00:25.38,Default,,0000,0000,0000,,so we should change the width\Nand the height of this eye. Dialogue: 0,0:00:25.38,0:00:28.50,Default,,0000,0000,0000,,No, now the eyes are a little too small,\Nso I should change them back. Dialogue: 0,0:00:28.71,0:00:30.84,Default,,0000,0000,0000,,Wouldn't I be great if I could\Njust change one number, Dialogue: 0,0:00:30.84,0:00:32.66,Default,,0000,0000,0000,,and have both eyes change? Dialogue: 0,0:00:32.88,0:00:36.19,Default,,0000,0000,0000,,And here is where {\i1}variables{\i0} come in. Dialogue: 0,0:00:37.23,0:00:40.85,Default,,0000,0000,0000,,Now, a variable is just like a name\Nor a placeholder for something else. Dialogue: 0,0:00:41.30,0:00:44.52,Default,,0000,0000,0000,,I like to think of a variable\Nas a big bucket with a name on it. Dialogue: 0,0:00:44.57,0:00:46.30,Default,,0000,0000,0000,,You can put anything\Nyou want in the bucket, Dialogue: 0,0:00:46.30,0:00:47.59,Default,,0000,0000,0000,,but the name stays the same. Dialogue: 0,0:00:47.75,0:00:51.94,Default,,0000,0000,0000,,We call the thing inside the bucket\Nthe {\i1}value{\i0} of the variable. Dialogue: 0,0:00:53.70,0:00:55.74,Default,,0000,0000,0000,,So let's start out by actually\Nmaking a variable. Dialogue: 0,0:00:55.74,0:00:57.56,Default,,0000,0000,0000,,I'm going to do it all the way up here. Dialogue: 0,0:00:57.56,0:01:00.33,Default,,0000,0000,0000,,All you do is type {\i1}var{\i0},\Nwhich stands for variable, Dialogue: 0,0:01:00.33,0:01:02.48,Default,,0000,0000,0000,,{\i1}Space{\i0}, and then\Nthe name of the variable, Dialogue: 0,0:01:02.48,0:01:04.46,Default,,0000,0000,0000,,which should describe\Nwhat the variable will hold. Dialogue: 0,0:01:04.46,0:01:06.01,Default,,0000,0000,0000,,So I'm going to call this one {\i1}eyeSize{\i0}. Dialogue: 0,0:01:06.01,0:01:07.100,Default,,0000,0000,0000,,And you can pretty much\Nname it whatever you want, Dialogue: 0,0:01:07.100,0:01:10.04,Default,,0000,0000,0000,,but you're not allowed to have\Nspaces between words. Dialogue: 0,0:01:10.04,0:01:11.97,Default,,0000,0000,0000,,And of course,\Ndon't forget that semicolon! Dialogue: 0,0:01:12.25,0:01:14.45,Default,,0000,0000,0000,,So now I've made\Na variable called {\i1}eyeSize{\i0}, Dialogue: 0,0:01:14.45,0:01:16.94,Default,,0000,0000,0000,,because it's going to hold\Nthe size of Winston's eyes. Dialogue: 0,0:01:16.94,0:01:19.51,Default,,0000,0000,0000,,But so far this variable\Ndoesn't have a value yet. Dialogue: 0,0:01:19.85,0:01:22.64,Default,,0000,0000,0000,,To give it one, we just say {\i1}eyeSize{\i0}, Dialogue: 0,0:01:22.64,0:01:27.19,Default,,0000,0000,0000,,and then an {\i1}={\i0}, and then {\i1}20;{\i0} . Dialogue: 0,0:01:27.61,0:01:29.37,Default,,0000,0000,0000,,Okay, now see that equal sign? Dialogue: 0,0:01:29.37,0:01:31.76,Default,,0000,0000,0000,,Forget whatever your math teacher\Ntaught you about it. Dialogue: 0,0:01:31.76,0:01:35.09,Default,,0000,0000,0000,,That equal sign does not mean "equals,"\Nit means assignment. Dialogue: 0,0:01:35.39,0:01:41.26,Default,,0000,0000,0000,,This means we're assigning\Nthe value {\i1}20{\i0} to the variable {\i1}eyeSize{\i0}. Dialogue: 0,0:01:42.01,0:01:43.72,Default,,0000,0000,0000,,In other words,\Nwe're putting the number 20 Dialogue: 0,0:01:43.72,0:01:45.58,Default,,0000,0000,0000,,into the bucket called, {\i1}eyeSize{\i0}. Dialogue: 0,0:01:45.73,0:01:48.44,Default,,0000,0000,0000,,And remember how in math class\Nyou can say stuff like, Dialogue: 0,0:01:48.44,0:01:51.82,Default,,0000,0000,0000,,x = 3, and 3 = x, Dialogue: 0,0:01:51.82,0:01:54.46,Default,,0000,0000,0000,,and it all means the same thing,\Nbecause {\i1}duuh{\i0}, they're equal? Dialogue: 0,0:01:54.46,0:01:56.38,Default,,0000,0000,0000,,Well, you can't do that here, either. Dialogue: 0,0:01:56.38,0:01:58.44,Default,,0000,0000,0000,,The thing on the left-hand side\Nof the equal sign Dialogue: 0,0:01:58.44,0:01:59.98,Default,,0000,0000,0000,,is always the variable. Dialogue: 0,0:01:59.98,0:02:03.40,Default,,0000,0000,0000,,And the thing on the right-hand side\Nof the equal sign is always the value Dialogue: 0,0:02:03.40,0:02:05.33,Default,,0000,0000,0000,,that you are assigning to the variable. Dialogue: 0,0:02:05.50,0:02:07.55,Default,,0000,0000,0000,,A good way to help you\Nremember which side is what Dialogue: 0,0:02:07.55,0:02:09.79,Default,,0000,0000,0000,,is while you're coding\Nand talking out loud to yourself, Dialogue: 0,0:02:09.79,0:02:11.49,Default,,0000,0000,0000,,like every cool programmer does, Dialogue: 0,0:02:11.49,0:02:15.29,Default,,0000,0000,0000,,if you hit an equal sign\Ndon't say "equals," say "gets." Dialogue: 0,0:02:15.29,0:02:18.59,Default,,0000,0000,0000,,So this becomes, {\i1}eyeSize{\i0} gets {\i1}20{\i0}. Dialogue: 0,0:02:19.62,0:02:22.05,Default,,0000,0000,0000,,And now, whenever I use\N{\i1}eyeSize{\i0} in my program, Dialogue: 0,0:02:22.05,0:02:24.78,Default,,0000,0000,0000,,the computer is going to be like,\N"Oh yeah, that's a variable, Dialogue: 0,0:02:24.78,0:02:27.87,Default,,0000,0000,0000,,I know what she {\i1}really{\i0} means\Nis this value 20." Dialogue: 0,0:02:28.31,0:02:31.13,Default,,0000,0000,0000,,So check it out--\NI'm just going to copy this, Dialogue: 0,0:02:31.42,0:02:34.40,Default,,0000,0000,0000,,and then replace these four numbers Dialogue: 0,0:02:34.78,0:02:37.06,Default,,0000,0000,0000,,with my new variable {\i1}eyeSize{\i0}, Dialogue: 0,0:02:38.26,0:02:39.61,Default,,0000,0000,0000,,and Voila! Dialogue: 0,0:02:39.61,0:02:43.92,Default,,0000,0000,0000,,Winston's eyes are now both\Nperfectly round and the same size, Dialogue: 0,0:02:43.92,0:02:46.59,Default,,0000,0000,0000,,and if I want to change\Nthe value of both eyes-- Dialogue: 0,0:02:46.59,0:02:47.73,Default,,0000,0000,0000,,or the size of both eyes, Dialogue: 0,0:02:47.73,0:02:50.55,Default,,0000,0000,0000,,I can just change the value\Nof this one variable. Dialogue: 0,0:02:51.00,0:02:53.04,Default,,0000,0000,0000,,Aah that's so cool! Dialogue: 0,0:02:54.31,0:02:55.67,Default,,0000,0000,0000,,Okay, couple of last notes. Dialogue: 0,0:02:55.67,0:02:58.51,Default,,0000,0000,0000,,Up here we made\Na new variable called {\i1}eyeSize{\i0}. Dialogue: 0,0:02:58.51,0:03:01.04,Default,,0000,0000,0000,,And here we gave it a value of {\i1}33{\i0}. Dialogue: 0,0:03:01.04,0:03:02.86,Default,,0000,0000,0000,,We can actually do that all in one step Dialogue: 0,0:03:02.86,0:03:05.93,Default,,0000,0000,0000,,by saying {\i1}var eyeSize{\i0},\Nthat's the first step, Dialogue: 0,0:03:05.93,0:03:08.72,Default,,0000,0000,0000,,gets {\i1}33{\i0},\Nthat's the second step. Dialogue: 0,0:03:08.72,0:03:10.82,Default,,0000,0000,0000,,And if I delete these two lines, Dialogue: 0,0:03:10.82,0:03:12.63,Default,,0000,0000,0000,,you can see everything still works. Dialogue: 0,0:03:13.45,0:03:16.76,Default,,0000,0000,0000,,Also remember that the computer\Nreads your code from top to bottom Dialogue: 0,0:03:16.76,0:03:19.19,Default,,0000,0000,0000,,so the only reason it knew\Nwhat {\i1}eyeSize{\i0} was down here, Dialogue: 0,0:03:19.19,0:03:21.67,Default,,0000,0000,0000,,was because we already\Ndefined it up here. Dialogue: 0,0:03:21.67,0:03:24.31,Default,,0000,0000,0000,,If I had put it down here instead, Dialogue: 0,0:03:25.02,0:03:28.45,Default,,0000,0000,0000,,then once we got to this line of code,\Nthe computer's going to be like, Dialogue: 0,0:03:28.45,0:03:30.99,Default,,0000,0000,0000,,"{\i1}eyeSize{\i0}, what the heck is {\i1}eyeSize{\i0}?\NI don't know what that is." Dialogue: 0,0:03:30.99,0:03:34.00,Default,,0000,0000,0000,,In fact, here we get an error that says\N{\i1}eyeSize{\i0} is not defined. Dialogue: 0,0:03:34.00,0:03:35.57,Default,,0000,0000,0000,,And maybe you're thinking to yourself, Dialogue: 0,0:03:35.57,0:03:37.48,Default,,0000,0000,0000,,"Yes, I did define it; it's right here!" Dialogue: 0,0:03:37.48,0:03:39.58,Default,,0000,0000,0000,,But the computer's not smart,\Nand doesn't get that. Dialogue: 0,0:03:40.41,0:03:42.64,Default,,0000,0000,0000,,So let's just move it back up to the top. Dialogue: 0,0:03:44.03,0:03:45.55,Default,,0000,0000,0000,,And you've got to always make sure Dialogue: 0,0:03:45.55,0:03:48.26,Default,,0000,0000,0000,,that you define your variable\Nbefore you try to use it. Dialogue: 0,0:03:49.14,0:03:51.91,Default,,0000,0000,0000,,And now you know\Nabout variables! Yaaay!