コード例 #1
0
ファイル: AABB.cs プロジェクト: Melody6149/GraphicalTestApp
 public bool DetectCollision(AABB other)
 {
     //## Implement DetectCollision(AABB) ##//
     if (Top < other.Bottom && Left < other.Right && Right > other.Left && Bottom > other.Top)
     {
         _color = Raylib.Color.BLUE;
         return(true);
     }
     _color = Raylib.Color.RED;
     return(false);
 }
コード例 #2
0
 //detects collision using AABB
 public bool DetectCollision(AABB other)
 {
     //return !(_max.x < other._min.x || _max.y < other._min.y || _min.x > other._max.x || _min.y > other._max.y)
     //test for overlapped as it exists faster
     if (Right >= other.Left && Bottom >= other.Top && Left <= other.Right && Top <= other.Bottom)
     {
         color = Raylib.Color.BLUE;
         return(true);
     }
     color = Raylib.Color.RED;
     return(false);
 }
コード例 #3
0
ファイル: AABB.cs プロジェクト: joshalbe/GraphicalTestApp
        public bool DetectCollision(AABB other)
        {
            //## Implement DetectCollision(AABB) ##//

            if (Right >= other.Left && Bottom >= other.Top && Left <= other.Right && Top <= other.Bottom)
            {
                color = Raylib.Color.BLUE;
                return(true);
            }

            return(false);
        }
コード例 #4
0
ファイル: AABB.cs プロジェクト: ryanlacombe/GraphicalTestApp
 //Checks a collision between two AABBs
 public bool DetectCollision(AABB other)
 {
     if (Right >= other.Left && Bottom >= other.Top && Left <= other.Right && Top <= other.Bottom)
     {
         _color = Raylib.Color.RED;
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #5
0
 public bool DetectCollision(AABB other)
 {
     if ((other.Left < Right) && (other.Bottom > Top) && (other.Top < Bottom) && (other.Right > Left))
     {
         _color = Raylib.Color.BLUE;
         return(true);
     }
     else
     {
         _color = Raylib.Color.RED;
         return(false);
     }
 }
コード例 #6
0
ファイル: AABB.cs プロジェクト: Melody6149/GraphicalTestApp
        //Draw the bounding box to the screen
        public override void Draw()
        {
            if (isPressed == true)
            {
                color = Raylib.Color.BLUE;
            }
            else
            {
                color = Raylib.Color.RED;
            }
            Raylib.Rectangle rec = new Raylib.Rectangle(Left, Top, Width, Height);

            Raylib.Raylib.DrawRectangleLinesEx(rec, 1, _color);
            base.Draw();
        }
コード例 #7
0
ファイル: AABB.cs プロジェクト: SheltonThomas/Asteroid-Game
 public bool DetectCollision(AABB other)
 {
     //## Implement DetectCollision(AABB) ##//
     if (((other.Left <= Right && other.Right >= Right) || (Left <= other.Right && Right >= other.Right)) &&
         ((other.Top <= Bottom && other.Bottom >= Bottom) || (Top <= other.Bottom && Bottom >= other.Bottom)))
     {
         _color = Raylib.Color.RED;
         return(true);
     }
     else
     {
         _color = Raylib.Color.GOLD;
         return(false);
     }
     //return false;
 }
コード例 #8
0
        //detect a collision
        public bool DetectCollision(AABB other)
        {
            //float[] sides = { other.Right, other.Left, other.Bottom, other.Top };
            //foreach (var side in sides)
            //{
            //    if (inRange(side, Left, Right, Top, Bottom))
            //    {
            //        color = Raylib.Color.BLUE;
            //        return true;
            //    }

            //}
            //return !(Top <= other.Bottom || Bottom >= other.Top ||
            //    Left <= other.Right || Right <= other.Right);
            if (Right >= other.Left && Bottom >= other.Top && Left <= other.Right && Top <= other.Bottom)
            {
                color = Raylib.Color.BLUE;
                return(true);
            }

            return(false);
        }