What do I have to do so that when I find out about the collision between two circles, I can prevent the two circles from going through one another?
public class CircleVsCircle
{
public Vector2 position { get; set; } //top left corner
public float CenterX;
public float CenterY;
public int Width { get; set; }
public int Height { get; set; }
}
public void CircleVsCircle(CircleBody body1, CircleBody body2)
{
float radius = (body1.Radius + body2.Radius);
radius *=radius;
float distance = ((body1.CenterX - body2.CenterX) *
(body1.CenterX - body2.CenterX)) +
((body1.CenterY - body2.CenterY) *
(body1.CenterY - body2.CenterY));
if(radius > distance)
{
//solve the collision here
}
}