Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript collision detection

function checkCollisions(x1, y1, w1, h1, x2, y2, w2, h2){
	if (x1 + w1 >= x2 && x1 + w1 <= x2 + w2 && y1 + h1 >= y2 && y1 + h1 <= y2 + h2) {
		return true;
	} else if (x1 >= x2 && x1 <= x2 + w2 && y1 >= y2 && y1 <= y2 + h2) {
		return true;
	} else {
		return false;
	}
}
 
PREVIOUS NEXT
Tagged: #javascript #collision #detection
ADD COMMENT
Topic
Name
6+9 =