public static bool IsColliding(AABB box1, AABB box2) { if (box1.Left > box2.Right) return false; if (box1.Right < box2.Left) return false; if (box1.Top < box2.Bottom) return false; if (box1.Bottom > box2.Top) return false; return true; }
protected void UpdateModelMatrix() { float halfSizeX = size.X * 0.5f; float halfSizeY = size.Y * 0.5f; boundingBox = new AABB(-halfSizeX + position.X, halfSizeX + position.X, halfSizeY + position.Y, -halfSizeY + position.Y); modelMatrix = Matrix4.CreateRotationZ(angle) * Matrix4.CreateTranslation(position.X, position.Y, 0); }
public bool IsColliding(AABB bounds) { if (bounds.Left < 0 || bounds.Right >= width || bounds.Top >= height || bounds.Bottom < 0) return true; for (int i = (int)bounds.Bottom; i <= (int)bounds.Top; i++) { for (int j = (int)bounds.Left; j <= (int)bounds.Right; j++) { if (collisionMap[i][j]) return true; } } return false; }