- Simple JQuery Game - How to know when two cars (divs) run into each other?
- function intersects(a,b)
- {
- if(a.x + a.w > b.x)
- sectHor = true;
- if(a.x < b.x + b.w)
- sectHor = true;
- if(a.y < b.y + b.h)
- sectVert = true;
- if(a.y + a.h > b.y)
- sectVert = true;
- if(sectHor && sectVert)
- return true;
- else return false;
- }