Diskuze: XNA - kolize, kruhové objekty
Zobrazeno 3 zpráv z 3.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Proč to tu máš 2x? Máš na mysli toto?
http://gamedev.stackexchange.com/…t-all-others
Každopádně stačí google - tam si vyber, co budeš potřebovat...
public static Vector2 GetIntersectionDepth(Circle a, Circle b)
{
float xValue = a.Center.X - b.Center.X;
float yValue = a.Center.Y - b.Center.Y;
Vector2 depth = Vector2.Zero;
float distance = Vector2.Distance(a.Center, b.Center);
if (a.Radius + b.Radius > distance)
{
float result = (a.Radius + b.Radius) - distance;
depth.X = (float)Math.Cos(result);
depth.Y = (float)Math.Sin(result);
}
return depth;
}
Vector2 depth = Vector2.Zero;
for (int i = 0; i < bounds.Count; i++)
for (int j = i+1; j < bounds.Count; j++)
{
depth = CircleToCircleIntersection.GetIntersectionDepth(bounds[i], bounds[j]);
if(depth == Vector2.Zero){
//this means that did not collide
}else{
//this means they collided
}
}
Zobrazeno 3 zpráv z 3.