Esempio n. 1
0
        public void CheckCollision(OBB shape)
        {
            List<bool> chkList = new List<bool>();
            foreach (Vector2 n in nList)
            {
              chkList.Add(CheckCollisionAlongAxis(n, shape));
            }
            foreach (Vector2 n in shape.nList)
            {
              chkList.Add(shape.CheckCollisionAlongAxis(n, this));
            }

            bool check = true;
            foreach (bool chk in chkList)
            {
              if (!chk) check = false;
            }
            if (check)
            {
              colliding = true;
              shape.colliding = true;
            }
        }
Esempio n. 2
0
        bool CheckCollisionAlongAxis(Vector2 axis, OBB shape)
        {
            MinMax mm1 = ProjectAlongAxis(axis);
            MinMax mm2 = shape.ProjectAlongAxis(axis);

            //DEBUG DRAW CODE
            //stroke(255);
            //PVector pp = PVector.mult(axis, mm1.center - mm2.center);
            //pp.add(box2.position);
            //line(shape.position.x, shape.position.y, pp.x, pp.y);
            //END

            if (mm2.min > mm1.max || mm1.min > mm2.max) return false;
            return true;
        }