[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:06.95,0:00:12.74,Default,,0000,0000,0000,,You're going to learn how math, like algebra\Nand geometry, can be used to develop video Dialogue: 0,0:00:12.74,0:00:13.98,Default,,0000,0000,0000,,games. Dialogue: 0,0:00:13.98,0:00:19.59,Default,,0000,0000,0000,,Some modern video games are incredibly complex,\Nwith realistic graphics, physics, artificial Dialogue: 0,0:00:19.59,0:00:21.98,Default,,0000,0000,0000,,intelligence and so on. Dialogue: 0,0:00:21.98,0:00:26.43,Default,,0000,0000,0000,,Major video games can take large teams of\Ndevelopers years to produce but you can apply Dialogue: 0,0:00:26.43,0:00:31.84,Default,,0000,0000,0000,,many of the same concepts that the big developers\Nuse to create a simple game of your own. Dialogue: 0,0:00:31.84,0:00:35.37,Default,,0000,0000,0000,,Let's start by looking at a fairly simple\N2-dimensional game. Dialogue: 0,0:00:35.37,0:00:40.77,Default,,0000,0000,0000,,Each of the actors, or sprites, in this game,\Ncan be described by their location or movement Dialogue: 0,0:00:40.77,0:00:42.30,Default,,0000,0000,0000,,on the screen. Dialogue: 0,0:00:42.30,0:00:46.43,Default,,0000,0000,0000,,Your job is to figure out how we can describe\Nthe actions of each of these sprites mathematically Dialogue: 0,0:00:46.43,0:00:49.59,Default,,0000,0000,0000,,in relation to the coordinate plane. Dialogue: 0,0:00:49.59,0:00:54.20,Default,,0000,0000,0000,,Let's take a quick look at the game Plants\Nvs. Zombies as an example. Dialogue: 0,0:00:54.20,0:00:58.05,Default,,0000,0000,0000,,If we have a zombie and a flower on the screen,\Nthere are a few things we need to know about Dialogue: 0,0:00:58.05,0:01:00.09,Default,,0000,0000,0000,,them in order to make the game work. Dialogue: 0,0:01:00.09,0:01:01.42,Default,,0000,0000,0000,,Where's the zombie? Dialogue: 0,0:01:01.42,0:01:04.80,Default,,0000,0000,0000,,In which direction is it moving?Where's the\Nflower? Dialogue: 0,0:01:04.80,0:01:07.68,Default,,0000,0000,0000,,How far apart are they? Dialogue: 0,0:01:07.68,0:01:11.97,Default,,0000,0000,0000,,As a player of the game, you might say in\Ngeneral terms that they're on opposite sides Dialogue: 0,0:01:11.97,0:01:13.10,Default,,0000,0000,0000,,of the screen. Dialogue: 0,0:01:13.10,0:01:15.61,Default,,0000,0000,0000,,Or that the zombie is moving to the left. Dialogue: 0,0:01:15.61,0:01:19.98,Default,,0000,0000,0000,,Or that the zombie and the flower are pretty\Nclose to each other. Dialogue: 0,0:01:19.98,0:01:25.03,Default,,0000,0000,0000,,These might be ok approximations but they\Nreally aren't specific enough and they definitely Dialogue: 0,0:01:25.03,0:01:28.75,Default,,0000,0000,0000,,aren't stated in a way that a computer can\Nunderstand. Dialogue: 0,0:01:28.75,0:01:32.44,Default,,0000,0000,0000,,Suppose you were talking to your friend on\Nthe phone, trying to tell them exactly where Dialogue: 0,0:01:32.44,0:01:34.20,Default,,0000,0000,0000,,the dragon is. Dialogue: 0,0:01:34.20,0:01:38.11,Default,,0000,0000,0000,,You could use words like on the left but that\Nisn't specific enough. Dialogue: 0,0:01:38.11,0:01:42.62,Default,,0000,0000,0000,,If you had a ruler, you could measure from\Nthe left side of the screen and tell your Dialogue: 0,0:01:42.62,0:01:45.99,Default,,0000,0000,0000,,friend exactly how many inches away the dragon\Nis. Dialogue: 0,0:01:45.99,0:01:48.55,Default,,0000,0000,0000,,That is exactly what computers do. Dialogue: 0,0:01:48.55,0:01:52.76,Default,,0000,0000,0000,,Using a number line that starts with a 0 on\Nthe far left and moving across the right measuring Dialogue: 0,0:01:52.76,0:01:55.90,Default,,0000,0000,0000,,the number of pixels on the screen. Dialogue: 0,0:01:55.90,0:02:00.12,Default,,0000,0000,0000,,For our video game, we'll place the number\Nline so that the screen runs from 0 on the Dialogue: 0,0:02:00.12,0:02:03.46,Default,,0000,0000,0000,,left to 400 on the right. Dialogue: 0,0:02:03.46,0:02:08.03,Default,,0000,0000,0000,,We can imagine the image of the dragon, stick\Nit anywhere on the line and measure the distance Dialogue: 0,0:02:08.03,0:02:13.09,Default,,0000,0000,0000,,back to the left hand edge of the screen from\Nour dragon. Dialogue: 0,0:02:13.09,0:02:17.13,Default,,0000,0000,0000,,Anyone else who knows about our number line\Nwill be able to duplicate the exact position Dialogue: 0,0:02:17.13,0:02:21.60,Default,,0000,0000,0000,,of the dragon know only the number. Dialogue: 0,0:02:21.60,0:02:24.45,Default,,0000,0000,0000,,On the right side of the screen, the dragon\Nis at 400. Dialogue: 0,0:02:24.45,0:02:27.91,Default,,0000,0000,0000,,In the center, he's at 200. Dialogue: 0,0:02:27.91,0:02:30.77,Default,,0000,0000,0000,,What if we wanted the dragon to be off the\Nedge of the screen? Dialogue: 0,0:02:30.77,0:02:35.24,Default,,0000,0000,0000,,We could use numbers bigger than 400 to place\Nhim past the right hand side and negative Dialogue: 0,0:02:35.24,0:02:39.24,Default,,0000,0000,0000,,numbers to place him past the left hand side. Dialogue: 0,0:02:39.24,0:02:43.47,Default,,0000,0000,0000,,But even with a number line, we aren't being\Nquite specific enough. Dialogue: 0,0:02:43.47,0:02:48.05,Default,,0000,0000,0000,,Even at 400, the dragon could be at the top\Nof the screen or at the bottom or anywhere Dialogue: 0,0:02:48.05,0:02:49.05,Default,,0000,0000,0000,,in between. Dialogue: 0,0:02:49.05,0:02:54.88,Default,,0000,0000,0000,,By adding another number line, we can locate\Na character anywhere on the screen in either Dialogue: 0,0:02:54.88,0:02:56.19,Default,,0000,0000,0000,,dimension. Dialogue: 0,0:02:56.19,0:03:00.79,Default,,0000,0000,0000,,The first line is called the x axis which\Nruns from left to right. Dialogue: 0,0:03:00.79,0:03:05.26,Default,,0000,0000,0000,,The second line which runs up and down is\Ncalled the y axis. Dialogue: 0,0:03:05.26,0:03:10.31,Default,,0000,0000,0000,,A 2-dimensional coordinate consists of both\Nthe x and y locations on the axis. Dialogue: 0,0:03:10.31,0:03:13.42,Default,,0000,0000,0000,,Suppose we want to locate ninja's position\Non the screen. Dialogue: 0,0:03:13.42,0:03:17.07,Default,,0000,0000,0000,,We can find the x coordinate by dropping a\Nline down from the ninja and read the position Dialogue: 0,0:03:17.07,0:03:18.42,Default,,0000,0000,0000,,on the number line. Dialogue: 0,0:03:18.42,0:03:22.41,Default,,0000,0000,0000,,The y coordinate is found by running a line\Nto the y axis. Dialogue: 0,0:03:22.41,0:03:27.21,Default,,0000,0000,0000,,With two numbers, x and y coordinates, we\Ncan describe the location of any sprite on Dialogue: 0,0:03:27.21,0:03:28.36,Default,,0000,0000,0000,,our screen. Dialogue: 0,0:03:28.36,0:03:33.04,Default,,0000,0000,0000,,And by changing those numbers, we can get\Nour sprites to move around on the screen. Dialogue: 0,0:03:33.04,0:03:36.98,Default,,0000,0000,0000,,What we've created is actually quadrant one\Nof the coordinate plane! Dialogue: 0,0:03:36.98,0:03:40.86,Default,,0000,0000,0000,,If we zoom out, we can see that there are\Nfour different quadrants to the plane: quadrant Dialogue: 0,0:03:40.86,0:03:46.16,Default,,0000,0000,0000,,I, which we're using as our screen, contains\Nthe points of positive values for x and y. Dialogue: 0,0:03:46.16,0:03:50.22,Default,,0000,0000,0000,,Moving counterclockwise we get to quadrant\NII which contains the points of a negative Dialogue: 0,0:03:50.22,0:03:52.35,Default,,0000,0000,0000,,X and positive Y. Dialogue: 0,0:03:52.35,0:03:57.46,Default,,0000,0000,0000,,Quadrant III contains all points with negative\NX and Y and quadrant IV contains all points Dialogue: 0,0:03:57.46,0:03:59.40,Default,,0000,0000,0000,,with a positive X and a negative Y.