[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.34,0:00:04.61,Default,,0000,0000,0000,,So now that we learned how to use text,\Nlet's get a bit more fancy. Dialogue: 0,0:00:04.61,0:00:06.01,Default,,0000,0000,0000,,The first fancy thing is that now we're Dialogue: 0,0:00:06.01,0:00:08.28,Default,,0000,0000,0000,,going to start using the word "string". Dialogue: 0,0:00:08.28,0:00:10.61,Default,,0000,0000,0000,,You might think, "String?\NThat's what my cat plays with." Dialogue: 0,0:00:10.61,0:00:12.72,Default,,0000,0000,0000,,But for programmers,\Nstring is a special name Dialogue: 0,0:00:12.72,0:00:14.58,Default,,0000,0000,0000,,we use for bits of text. Dialogue: 0,0:00:14.58,0:00:16.57,Default,,0000,0000,0000,,You can think of it like\Na string of characters, if it helps. Dialogue: 0,0:00:16.57,0:00:19.07,Default,,0000,0000,0000,,Your name is a string,\Nyour school's name is a string, Dialogue: 0,0:00:19.07,0:00:22.10,Default,,0000,0000,0000,,and every text message\Nyou've ever sent is also a string. Dialogue: 0,0:00:22.10,0:00:25.50,Default,,0000,0000,0000,,Basically, just think, string equals text. Dialogue: 0,0:00:25.98,0:00:28.56,Default,,0000,0000,0000,,So we used drawing\Nand coloring with strings already. Dialogue: 0,0:00:28.56,0:00:30.99,Default,,0000,0000,0000,,Could we use variables\Nwith strings? Of course! Dialogue: 0,0:00:30.99,0:00:33.22,Default,,0000,0000,0000,,Just like you might normally\Nput a number into a variable, Dialogue: 0,0:00:33.22,0:00:35.23,Default,,0000,0000,0000,,you could also put a string\Ninto a variable. Dialogue: 0,0:00:35.45,0:00:37.39,Default,,0000,0000,0000,,We just say something like, Dialogue: 0,0:00:37.39,0:00:40.96,Default,,0000,0000,0000,,"var myName = (whatever your name is)"\Nso "Sophia"; Dialogue: 0,0:00:40.96,0:00:42.60,Default,,0000,0000,0000,,remembering those quotes. Dialogue: 0,0:00:42.60,0:00:44.48,Default,,0000,0000,0000,,And then we put the variable myName Dialogue: 0,0:00:44.48,0:00:46.80,Default,,0000,0000,0000,,into the quoted text\Ninstead of writing "Sophia" directly, Dialogue: 0,0:00:46.80,0:00:48.54,Default,,0000,0000,0000,,like we were doing before. Dialogue: 0,0:00:48.54,0:00:50.53,Default,,0000,0000,0000,,And this way though it\Nlooks the same right now, Dialogue: 0,0:00:50.53,0:00:53.30,Default,,0000,0000,0000,,we can actually,\Nwrite this multiple times Dialogue: 0,0:00:53.30,0:00:55.33,Default,,0000,0000,0000,,you know, one time there, one time there, Dialogue: 0,0:00:55.33,0:00:57.32,Default,,0000,0000,0000,,you know maybe we\Ncan be a little artistical. Dialogue: 0,0:00:57.32,0:00:59.40,Default,,0000,0000,0000,,And then all you have to do\Nis to change this one variable Dialogue: 0,0:00:59.40,0:01:02.01,Default,,0000,0000,0000,,to be {\i1}your{\i0} name, and then you have Dialogue: 0,0:01:02.01,0:01:04.02,Default,,0000,0000,0000,,your name written three times. Dialogue: 0,0:01:04.02,0:01:07.23,Default,,0000,0000,0000,,So, just flipping that back,\Nwhat if we want to get Dialogue: 0,0:01:07.23,0:01:09.54,Default,,0000,0000,0000,,kind of crazy, can we\Nstart adding together strings? Dialogue: 0,0:01:09.54,0:01:12.82,Default,,0000,0000,0000,,Like you remember when we maybe\Nstarted adding together variables? Dialogue: 0,0:01:12.82,0:01:14.58,Default,,0000,0000,0000,,Well we can actually do that, Dialogue: 0,0:01:14.58,0:01:17.06,Default,,0000,0000,0000,,the computer will just\Nstick the two strings together. Dialogue: 0,0:01:17.06,0:01:19.55,Default,,0000,0000,0000,,So for example, you know,\Nwe can get rid of this, Dialogue: 0,0:01:19.55,0:01:22.25,Default,,0000,0000,0000,,to do it only one time\Nand then we can use this other variable Dialogue: 0,0:01:22.25,0:01:27.08,Default,,0000,0000,0000,,message that's going to be my name,\Nplus say a bunch of exclamation marks. Dialogue: 0,0:01:27.75,0:01:30.30,Default,,0000,0000,0000,,And if we stick message into text\Nto draw this variable Dialogue: 0,0:01:30.30,0:01:32.83,Default,,0000,0000,0000,,instead of my name,\Nwe can see that Dialogue: 0,0:01:32.83,0:01:34.64,Default,,0000,0000,0000,,all it did is just stuck those exclamation marks Dialogue: 0,0:01:34.64,0:01:37.31,Default,,0000,0000,0000,,that we had onto the back of my name. Dialogue: 0,0:01:38.06,0:01:40.17,Default,,0000,0000,0000,,And we can even make this\Na little bit more exciting, Dialogue: 0,0:01:40.17,0:01:42.96,Default,,0000,0000,0000,,if we wanted to write message, say, twice. Dialogue: 0,0:01:42.96,0:01:46.07,Default,,0000,0000,0000,,So this looks pretty reasonable,\Nyou know adding strings means Dialogue: 0,0:01:46.07,0:01:49.03,Default,,0000,0000,0000,,you stick one string\Nonto the back of the other string. Dialogue: 0,0:01:49.03,0:01:51.63,Default,,0000,0000,0000,,But you might be thinking,\Ncan we get really crazy? Dialogue: 0,0:01:51.63,0:01:54.55,Default,,0000,0000,0000,,And start multiplying or dividing\Nor subtracting strings? Dialogue: 0,0:01:54.55,0:01:57.35,Default,,0000,0000,0000,,Could we do that? Well no we can't, Dialogue: 0,0:01:57.35,0:01:59.33,Default,,0000,0000,0000,,with strings we can only add them. Dialogue: 0,0:01:59.33,0:02:01.75,Default,,0000,0000,0000,,You're right that we could divide\Nand subtract with number variables, Dialogue: 0,0:02:01.75,0:02:04.66,Default,,0000,0000,0000,,but string variables only allow us to add. Dialogue: 0,0:02:04.66,0:02:07.44,Default,,0000,0000,0000,,But still being curious and asking\Nthose sorts of questions, Dialogue: 0,0:02:07.44,0:02:09.53,Default,,0000,0000,0000,,is the right attitude in programming. Dialogue: 0,0:02:09.53,0:02:11.86,Default,,0000,0000,0000,,You might think, "What would\Nit mean to divide a string?" Dialogue: 0,0:02:13.13,0:02:16.93,Default,,0000,0000,0000,,So we can also use animation\Nand mouse interaction with text strings. Dialogue: 0,0:02:17.50,0:02:20.29,Default,,0000,0000,0000,,For example, we can make the string\Nfollow the mouse around. Dialogue: 0,0:02:20.29,0:02:23.19,Default,,0000,0000,0000,,Just by sticking it in a draw loop\Nlike we did with the rectangles. Dialogue: 0,0:02:23.48,0:02:26.42,Default,,0000,0000,0000,,So if you think about how to do this,\Nwe would say var draw, Dialogue: 0,0:02:26.80,0:02:29.66,Default,,0000,0000,0000,,and then we'll stick all of this, right in here. Dialogue: 0,0:02:29.66,0:02:32.90,Default,,0000,0000,0000,,This probably looks really familiar,\Nfrom "intro to animation." Dialogue: 0,0:02:32.90,0:02:36.33,Default,,0000,0000,0000,,And you might think, alright, well to\Nmake it follow the mouse around, Dialogue: 0,0:02:36.33,0:02:39.46,Default,,0000,0000,0000,,we certainly need to use\NmouseX, and mouseY Dialogue: 0,0:02:39.46,0:02:43.19,Default,,0000,0000,0000,,and there you have it we're\Nactually painting with our name. Dialogue: 0,0:02:43.19,0:02:46.82,Default,,0000,0000,0000,,And of course if we wanted,\Nwe could easily set a background, Dialogue: 0,0:02:46.82,0:02:50.83,Default,,0000,0000,0000,,say to, you know, a nice light blue. Dialogue: 0,0:02:50.83,0:02:55.08,Default,,0000,0000,0000,,And now we have that the text\Nis just following the mouse around, Dialogue: 0,0:02:55.08,0:02:56.80,Default,,0000,0000,0000,,just like we saw with the rectangles. Dialogue: 0,0:02:57.19,0:03:00.13,Default,,0000,0000,0000,,And now as a last fun trick,\Nlet's use animation, Dialogue: 0,0:03:00.13,0:03:02.64,Default,,0000,0000,0000,,and make the text size\Ngrow and grow and grow. Dialogue: 0,0:03:02.64,0:03:06.23,Default,,0000,0000,0000,,So, here we're setting the textSize to 30,\Nas we learned in variables Dialogue: 0,0:03:06.23,0:03:10.79,Default,,0000,0000,0000,,instead of using 30, we could also say,\Nvar howBig equals 30; Dialogue: 0,0:03:10.79,0:03:14.20,Default,,0000,0000,0000,,and then use this variable\Ninstead of doing 30 directly. Dialogue: 0,0:03:14.65,0:03:16.42,Default,,0000,0000,0000,,Well that's the exact same thing, Dialogue: 0,0:03:16.42,0:03:18.65,Default,,0000,0000,0000,,and we need to obviously\Nbe changing something Dialogue: 0,0:03:18.65,0:03:20.48,Default,,0000,0000,0000,,in order to get an animation. Dialogue: 0,0:03:20.48,0:03:25.42,Default,,0000,0000,0000,,So we can do that by saying,\Nhow big equals how big plus one Dialogue: 0,0:03:25.42,0:03:28.31,Default,,0000,0000,0000,,which actually means,\Nif you remember howBig gets, Dialogue: 0,0:03:28.31,0:03:32.21,Default,,0000,0000,0000,,you know how big it was before,\Nplus one to make it a little bit larger Dialogue: 0,0:03:32.21,0:03:34.75,Default,,0000,0000,0000,,and now we just need to\Nrestart the program, Dialogue: 0,0:03:34.75,0:03:37.50,Default,,0000,0000,0000,,and here we have that\Nas we're moving the mouse around, Dialogue: 0,0:03:37.50,0:03:39.86,Default,,0000,0000,0000,,the text size is growing and growing\Nand growing and growing Dialogue: 0,0:03:39.86,0:03:41.94,Default,,0000,0000,0000,,because of this line right here. Dialogue: 0,0:03:43.26,0:03:44.72,Default,,0000,0000,0000,,And you know, just on your own,\N Dialogue: 0,0:03:44.72,0:03:47.59,Default,,0000,0000,0000,,you might think, okay how\Ncan we make it grow faster? Dialogue: 0,0:03:48.09,0:03:51.65,Default,,0000,0000,0000,,So now, not only do you know how\Nto manipulate shapes with code, Dialogue: 0,0:03:51.65,0:03:54.77,Default,,0000,0000,0000,,but you can also use text with code as well.