Ejemplo n.º 1
0
            public bool checkCollision(collisionCircle circe)
            {
                Vector2 distanceVector2 = center - circe.getCenter();
                float   radii           = radius + circe.getRadius();

                if (distanceVector2.Length() < radii)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Ejemplo n.º 2
0
            //----------------------------------------------COLLISION-CHECKING---------------------------------------

            public bool checkCollision(collisionCircle circe)
            {
                Vector2 distanceVector = Vector2.Zero;

                //Check position of circle
                //Check if to the left...
                if (circe.getCenter().X < position.X)
                {
                    if (circe.getCenter().Y >= position.Y && circe.getCenter().Y < (position.Y + height))
                    {
                        //Circle is to the left, and within the correct height co-ordinates
                        distanceVector = Left - circe.getCenter();
                        if (distanceVector.Length() < circe.getRadius())
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                //Check if to the right...
                else if (circe.getCenter().X > (position.X + width))
                {
                    if (circe.getCenter().Y >= position.Y && circe.getCenter().Y < (position.Y + height))
                    {
                        //Circle is to the right, and within the bounds of the right side
                        distanceVector = Right - circe.getCenter();
                        if (distanceVector.Length() < circe.getRadius())
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                //Check if above...
                else if (circe.getCenter().Y < position.Y)
                {
                    if (circe.getCenter().X >= position.X && circe.getCenter().X < (position.X + width))
                    {
                        distanceVector = Top - circe.getCenter();
                        if (distanceVector.Length() < circe.getRadius())
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                //check if below...
                else if (circe.getCenter().Y > position.Y)
                {
                    distanceVector = Bottom - circe.getCenter();
                    if (distanceVector.Length() < circe.getRadius())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(false);
            }