YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Intersecting Rectangles - HTML5 Game Development

Get Embed Code
3 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. Remember how we talked about actually writing code to do intersection between
  2. two rectangles? We've actually abstracted that away and actually turned it into
  3. a function inside of gMaps. You can call gMap.intersectRect. The isVisible
  4. function is actually a nice little helper that will pass in the viewRect and the
  5. rectangle for this tile Into the intersectRect function to determine whether or
  6. not this tile is visible to the current view rectangle. This is a helpful little
  7. function that we'll utilize in a couple different places moving forward. Now,
  8. before moving forward let's go ahead and write this intersectRect function so
  9. that it takes two rectangles with top, bottom, left, and right values and
  10. returns whether or not they intersect.