Actually I am trying to detect thee collision of the Rectangle with the circle in the following piece of code:-
function checkCollision() {
//checking of the Collision
if (ry + rh > cy - radius && rx + rw > cx - radius && rx + rw < cx + radius ) {
dy = -dy;
}
}
This is also the part of my code:-
var rx = 50; //distance from the x-axis of the Rect.
var ry = 50; //distance from the y-axis of the Rect.
var rw = 80; //width of the Rect
var rh = 30; //Height of the Rect.
// Distance to moved of the Rect.
var dx = 2;
var dy = 2;
// Center of the circle from the x-axis and y-axis.
var cx = 105;
var cy = 135;
var radius = 16;
var cx1 = 6;
var cy1 = 6;
Can anyone help me out here to figure out what is wrong?