< Return to Video

CS in Algebra: Big Game Collision Detection

  • 0:02 - 0:11
    All the sprites in your big game are now animated.
  • 0:11 - 0:14
    But nothing happens when they run into each
    other.
  • 0:14 - 0:18
    We're going to use collision detection to
    find out when sprites have touched each other
  • 0:18 - 0:23
    so that we can later apply rules like increasing
    or decreasing your score when your sprites
  • 0:23 - 0:24
    collide.
  • 0:24 - 0:30
    Using the provided line-length function, you
    will complete a function distance that uses
  • 0:30 - 0:36
    the distance formula to calculate the distance
    between the center points of two sprites.
  • 0:36 - 0:40
    Next you'll update the collide function to
    use the distance function.
  • 0:40 - 0:45
    If the distance between two sprites is less
    than 100 pixels, the sprites are close enough
  • 0:45 - 0:50
    to be touching and the collide function should
    return true.
  • 0:50 - 0:54
    If everything works, you'll see that when
    the player collides with the target, your
  • 0:54 - 0:56
    score increases.
  • 0:56 - 1:00
    And when the player collides with the danger,
    your score decreases.
Title:
CS in Algebra: Big Game Collision Detection
Description:

more » « less
Duration:
01:08

English subtitles

Revisions