Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 0.37 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Simple JQuery Game - How to know when two cars (divs) run into each other?
  2. function intersects(a,b)
  3. {
  4.     if(a.x + a.w > b.x)
  5.         sectHor = true;
  6.     if(a.x < b.x + b.w)
  7.         sectHor = true;
  8.     if(a.y < b.y + b.h)
  9.         sectVert = true;
  10.     if(a.y + a.h > b.y)
  11.         sectVert = true;
  12.  
  13.     if(sectHor && sectVert)
  14.         return true;
  15.     else return false;
  16. }