< Return to Video

CS in Algebra: Coordinate Plane

  • 0:07 - 0:13
    You're going to learn how math, like algebra
    and geometry, can be used to develop video
  • 0:13 - 0:14
    games.
  • 0:14 - 0:20
    Some modern video games are incredibly complex,
    with realistic graphics, physics, artificial
  • 0:20 - 0:22
    intelligence and so on.
  • 0:22 - 0:26
    Major video games can take large teams of
    developers years to produce but you can apply
  • 0:26 - 0:32
    many of the same concepts that the big developers
    use to create a simple game of your own.
  • 0:32 - 0:35
    Let's start by looking at a fairly simple
    2-dimensional game.
  • 0:35 - 0:41
    Each of the actors, or sprites, in this game,
    can be described by their location or movement
  • 0:41 - 0:42
    on the screen.
  • 0:42 - 0:46
    Your job is to figure out how we can describe
    the actions of each of these sprites mathematically
  • 0:46 - 0:50
    in relation to the coordinate plane.
  • 0:50 - 0:54
    Let's take a quick look at the game Plants
    vs. Zombies as an example.
  • 0:54 - 0:58
    If we have a zombie and a flower on the screen,
    there are a few things we need to know about
  • 0:58 - 1:00
    them in order to make the game work.
  • 1:00 - 1:01
    Where's the zombie?
  • 1:01 - 1:05
    In which direction is it moving?Where's the
    flower?
  • 1:05 - 1:08
    How far apart are they?
  • 1:08 - 1:12
    As a player of the game, you might say in
    general terms that they're on opposite sides
  • 1:12 - 1:13
    of the screen.
  • 1:13 - 1:16
    Or that the zombie is moving to the left.
  • 1:16 - 1:20
    Or that the zombie and the flower are pretty
    close to each other.
  • 1:20 - 1:25
    These might be ok approximations but they
    really aren't specific enough and they definitely
  • 1:25 - 1:29
    aren't stated in a way that a computer can
    understand.
  • 1:29 - 1:32
    Suppose you were talking to your friend on
    the phone, trying to tell them exactly where
  • 1:32 - 1:34
    the dragon is.
  • 1:34 - 1:38
    You could use words like on the left but that
    isn't specific enough.
  • 1:38 - 1:43
    If you had a ruler, you could measure from
    the left side of the screen and tell your
  • 1:43 - 1:46
    friend exactly how many inches away the dragon
    is.
  • 1:46 - 1:49
    That is exactly what computers do.
  • 1:49 - 1:53
    Using a number line that starts with a 0 on
    the far left and moving across the right measuring
  • 1:53 - 1:56
    the number of pixels on the screen.
  • 1:56 - 2:00
    For our video game, we'll place the number
    line so that the screen runs from 0 on the
  • 2:00 - 2:03
    left to 400 on the right.
  • 2:03 - 2:08
    We can imagine the image of the dragon, stick
    it anywhere on the line and measure the distance
  • 2:08 - 2:13
    back to the left hand edge of the screen from
    our dragon.
  • 2:13 - 2:17
    Anyone else who knows about our number line
    will be able to duplicate the exact position
  • 2:17 - 2:22
    of the dragon know only the number.
  • 2:22 - 2:24
    On the right side of the screen, the dragon
    is at 400.
  • 2:24 - 2:28
    In the center, he's at 200.
  • 2:28 - 2:31
    What if we wanted the dragon to be off the
    edge of the screen?
  • 2:31 - 2:35
    We could use numbers bigger than 400 to place
    him past the right hand side and negative
  • 2:35 - 2:39
    numbers to place him past the left hand side.
  • 2:39 - 2:43
    But even with a number line, we aren't being
    quite specific enough.
  • 2:43 - 2:48
    Even at 400, the dragon could be at the top
    of the screen or at the bottom or anywhere
  • 2:48 - 2:49
    in between.
  • 2:49 - 2:55
    By adding another number line, we can locate
    a character anywhere on the screen in either
  • 2:55 - 2:56
    dimension.
  • 2:56 - 3:01
    The first line is called the x axis which
    runs from left to right.
  • 3:01 - 3:05
    The second line which runs up and down is
    called the y axis.
  • 3:05 - 3:10
    A 2-dimensional coordinate consists of both
    the x and y locations on the axis.
  • 3:10 - 3:13
    Suppose we want to locate ninja's position
    on the screen.
  • 3:13 - 3:17
    We can find the x coordinate by dropping a
    line down from the ninja and read the position
  • 3:17 - 3:18
    on the number line.
  • 3:18 - 3:22
    The y coordinate is found by running a line
    to the y axis.
  • 3:22 - 3:27
    With two numbers, x and y coordinates, we
    can describe the location of any sprite on
  • 3:27 - 3:28
    our screen.
  • 3:28 - 3:33
    And by changing those numbers, we can get
    our sprites to move around on the screen.
  • 3:33 - 3:37
    What we've created is actually quadrant one
    of the coordinate plane!
  • 3:37 - 3:41
    If we zoom out, we can see that there are
    four different quadrants to the plane: quadrant
  • 3:41 - 3:46
    I, which we're using as our screen, contains
    the points of positive values for x and y.
  • 3:46 - 3:50
    Moving counterclockwise we get to quadrant
    II which contains the points of a negative
  • 3:50 - 3:52
    X and positive Y.
  • 3:52 - 3:57
    Quadrant III contains all points with negative
    X and Y and quadrant IV contains all points
  • 3:57 - 3:59
    with a positive X and a negative Y.
Title:
CS in Algebra: Coordinate Plane
Description:

more » « less
Video Language:
English
Duration:
04:02

English subtitles

Revisions