[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.34,0:00:04.54,Default,,0000,0000,0000,,Let's talk about more complex conditions\Nyou can check with your programs. Dialogue: 0,0:00:04.84,0:00:06.63,Default,,0000,0000,0000,,To demonstrate, I've set up my canvas Dialogue: 0,0:00:06.63,0:00:09.39,Default,,0000,0000,0000,,to look kind like an old game\NI used to play: Foursquare. Dialogue: 0,0:00:09.39,0:00:11.83,Default,,0000,0000,0000,,There is four squares\N- it's got a good name-, Dialogue: 0,0:00:11.83,0:00:14.83,Default,,0000,0000,0000,,and you stand in one and bounce\Nyour ball to the other squares. Dialogue: 0,0:00:14.83,0:00:17.28,Default,,0000,0000,0000,,So right now, I'll draw an ellipse\Nwherever my mouse is, Dialogue: 0,0:00:17.28,0:00:19.00,Default,,0000,0000,0000,,so that's like our ball. Dialogue: 0,0:00:19.00,0:00:21.77,Default,,0000,0000,0000,,What I wanna do is highlight\Nthe square that the ball is in, Dialogue: 0,0:00:21.77,0:00:24.20,Default,,0000,0000,0000,,by drawing a white rectangle on top of it. Dialogue: 0,0:00:24.20,0:00:26.11,Default,,0000,0000,0000,,I know I need an {\i1}if{\i0} statement to do that, Dialogue: 0,0:00:26.11,0:00:28.23,Default,,0000,0000,0000,,because I only want\Nto do it to one at a time, Dialogue: 0,0:00:28.23,0:00:30.40,Default,,0000,0000,0000,,only when I am over that rectangle. Dialogue: 0,0:00:30.40,0:00:34.00,Default,,0000,0000,0000,,Okay, so let's start\Nby drawing that rectangle. Dialogue: 0,0:00:35.04,0:00:40.44,Default,,0000,0000,0000,,So I'll just copy the {\i1}rect{\i0} from there,\Nbut give it a different fill, a white one. Dialogue: 0,0:00:41.37,0:00:44.50,Default,,0000,0000,0000,,Good. Now let's wrap it with an {\i1}if{\i0}. Dialogue: 0,0:00:45.63,0:00:49.96,Default,,0000,0000,0000,,You see it auto-completes the curly braces\Nfor me, so I got to move it inside. Dialogue: 0,0:00:50.60,0:00:53.76,Default,,0000,0000,0000,,OK. So when do I want\Nto show that rectangle? Dialogue: 0,0:00:54.24,0:01:00.98,Default,,0000,0000,0000,,Well, I know I wanna do it when mouse\N{\i1}mouseX < 200{\i0}. Dialogue: 0,0:01:02.97,0:01:07.46,Default,,0000,0000,0000,,So that works, but then if I go\Ndown here, it is still showing. Dialogue: 0,0:01:07.46,0:01:09.90,Default,,0000,0000,0000,,So I also need to check {\i1}mouseY{\i0}. Dialogue: 0,0:01:09.90,0:01:12.72,Default,,0000,0000,0000,,Well, how do I check {\i1}both{\i0} of those things? Dialogue: 0,0:01:12.72,0:01:14.83,Default,,0000,0000,0000,,That’s why we have the "and" operator. Dialogue: 0,0:01:14.83,0:01:18.07,Default,,0000,0000,0000,,So the {\i1}and{\i0} operator we use\Nwhen we want to check multiple conditions. Dialogue: 0,0:01:18.07,0:01:23.35,Default,,0000,0000,0000,,So we just write {\i1}&&{\i0} \Nand then we write our next condition, Dialogue: 0,0:01:23.35,0:01:26.32,Default,,0000,0000,0000,,so {\i1}mouseY < 200{\i0}. Dialogue: 0,0:01:26.78,0:01:30.81,Default,,0000,0000,0000,,So it doesn't light over here\Nanymore, and it does here! Yay. Dialogue: 0,0:01:30.81,0:01:35.81,Default,,0000,0000,0000,,Let's do the next square,\Njust to prove this works. Dialogue: 0,0:01:35.81,0:01:38.94,Default,,0000,0000,0000,,Alright, so we just have\Nto change some stuff. Dialogue: 0,0:01:38.94,0:01:40.77,Default,,0000,0000,0000,,Well take this rectangle instead, Dialogue: 0,0:01:40.77,0:01:44.43,Default,,0000,0000,0000,,and we obviously need\Nto change the conditions Dialogue: 0,0:01:44.43,0:01:45.82,Default,,0000,0000,0000,,so it's not so lighting up. Dialogue: 0,0:01:45.82,0:01:50.70,Default,,0000,0000,0000,,So this time, mouseX needs \Nto be greater than 200, Dialogue: 0,0:01:50.70,0:01:53.56,Default,,0000,0000,0000,,and mouseY still less than 200. Dialogue: 0,0:01:53.56,0:01:55.07,Default,,0000,0000,0000,,Beautiful, look at that! Dialogue: 0,0:01:55.07,0:01:59.70,Default,,0000,0000,0000,,Alright, now, in foursquare,\Nwhenever the ball hits the edges, Dialogue: 0,0:01:59.70,0:02:02.50,Default,,0000,0000,0000,,you know, these lines\Nin the middle and corners, Dialogue: 0,0:02:02.50,0:02:04.50,Default,,0000,0000,0000,,we always yell "EdgeBall". Dialogue: 0,0:02:04.50,0:02:10.20,Default,,0000,0000,0000,,So I wanna do that here too.\NLet's start by writing it {\i1}EDGE BALLL!!!!{\i0}. Dialogue: 0,0:02:10.20,0:02:15.96,Default,,0000,0000,0000,,And let's write in the middle \Nand make it red, 'cuz is really important. Dialogue: 0,0:02:15.96,0:02:19.37,Default,,0000,0000,0000,,So I only want it to happen\Nif I'm on the edges. Dialogue: 0,0:02:20.13,0:02:22.57,Default,,0000,0000,0000,,So we are gonna add our {\i1}if{\i0}, Dialogue: 0,0:02:22.57,0:02:24.53,Default,,0000,0000,0000,,and move this code inside of it. Dialogue: 0,0:02:25.61,0:02:28.76,Default,,0000,0000,0000,,When I want it to happen? Dialogue: 0,0:02:28.76,0:02:30.20,Default,,0000,0000,0000,,Well, there is edges in the middle, Dialogue: 0,0:02:30.20,0:02:36.04,Default,,0000,0000,0000,,so the middle is when {\i1}mouseX equals 200{\i0}. Dialogue: 0,0:02:37.33,0:02:40.90,Default,,0000,0000,0000,,Alright let's see. Do I get Edge Ball? Dialogue: 0,0:02:40.90,0:02:44.64,Default,,0000,0000,0000,,There we go! {\i1}EDGE BALL!!!{\i0} Dialogue: 0,0:02:44.64,0:02:49.42,Default,,0000,0000,0000,,OK. Hmm... So that works\Nin this middle line here, Dialogue: 0,0:02:49.42,0:02:52.30,Default,,0000,0000,0000,,but I also want it\Nto work on this line here. Dialogue: 0,0:02:52.30,0:02:58.02,Default,,0000,0000,0000,,In that case, I want {\i1}mouseY equals 200{\i0}, Dialogue: 0,0:02:58.53,0:03:01.53,Default,,0000,0000,0000,,because that’s what that middle line is. Dialogue: 0,0:03:02.26,0:03:07.76,Default,,0000,0000,0000,,Let's see, so that's not working.\NNothing is working. Dialogue: 0,0:03:08.32,0:03:10.73,Default,,0000,0000,0000,,Oh, one thing works, just the very center. Dialogue: 0,0:03:10.73,0:03:12.44,Default,,0000,0000,0000,,Well, that’s because I used an {\i1}and{\i0}, Dialogue: 0,0:03:12.44,0:03:16.27,Default,,0000,0000,0000,,so its only gonna do it\Nif {\i1}both{\i0} of these are true, Dialogue: 0,0:03:16.27,0:03:18.39,Default,,0000,0000,0000,,and it will only happen in the center. Dialogue: 0,0:03:18.39,0:03:22.03,Default,,0000,0000,0000,,So what I actually wanna say is,\N{\i1}either{\i0} one of these are true. Dialogue: 0,0:03:22.03,0:03:24.70,Default,,0000,0000,0000,,So we use the {\i1}or{\i0} operator. Dialogue: 0,0:03:24.70,0:03:27.32,Default,,0000,0000,0000,,So the {\i1}or{\i0} operator looks like this: {\i1}||{\i0} Dialogue: 0,0:03:27.32,0:03:31.53,Default,,0000,0000,0000,,We call those pipe symbols,\Nand you probably never used them before. Dialogue: 0,0:03:31.53,0:03:35.76,Default,,0000,0000,0000,,You have to look it on your keyboard,\Nit is usually on your top-right. Dialogue: 0,0:03:35.76,0:03:39.47,Default,,0000,0000,0000,,Hopefully, you actually\Nhave it on your keyboard. Dialogue: 0,0:03:39.47,0:03:42.27,Default,,0000,0000,0000,,Alright? Cool, so now\Nlet's see if it works. Dialogue: 0,0:03:42.27,0:03:46.03,Default,,0000,0000,0000,,Alright, so works there, works there,\Nand then works there. Beautiful. Dialogue: 0,0:03:46.03,0:03:49.12,Default,,0000,0000,0000,,We can keep adding more conditions here, Dialogue: 0,0:03:49.12,0:03:52.70,Default,,0000,0000,0000,,so with both {\i1}and{\i0} and {\i1}or{\i0}\Nyou can have as many of these as you want Dialogue: 0,0:03:52.70,0:03:54.60,Default,,0000,0000,0000,,If you need to check\N60 different conditions Dialogue: 0,0:03:54.60,0:03:56.36,Default,,0000,0000,0000,,you can totally do that, right? Dialogue: 0,0:03:56.36,0:03:58.33,Default,,0000,0000,0000,,Because we haven’t take\Ncare of our edges yet, Dialogue: 0,0:03:58.33,0:04:04.44,Default,,0000,0000,0000,,so let's say if mouseX is less than 3, Dialogue: 0,0:04:05.23,0:04:07.96,Default,,0000,0000,0000,,so that should be--\Nthere we go, that little edge there. Dialogue: 0,0:04:07.96,0:04:09.30,Default,,0000,0000,0000,,Very good. Dialogue: 0,0:04:09.30,0:04:14.53,Default,,0000,0000,0000,,Or {\i1}(mouseX>397){\i0} Dialogue: 0,0:04:15.13,0:04:17.60,Default,,0000,0000,0000,,There we go! Beautiful! Dialogue: 0,0:04:17.60,0:04:20.53,Default,,0000,0000,0000,,So we keep doing it for all the edges. Dialogue: 0,0:04:20.53,0:04:24.54,Default,,0000,0000,0000,,So.. yeah! There is {\i1}and{\i0} (&&) and {\i1}or{\i0} (||)\Nand now you can see Dialogue: 0,0:04:24.54,0:04:27.57,Default,,0000,0000,0000,,how you can build up much more\Ncomplex conditions in your programs. Dialogue: 0,0:04:27.57,0:04:30.47,Default,,0000,0000,0000,,And that's good,\Nbecause the world is a complex place.