Example #1
0
        bool CheckCollisions()
        {
            if (Active())
            {
                for (int shot = 0; shot < 4; shot++)
                {
                    if (m_Player.m_Shots[shot].Active())
                    {
                        if (CirclesIntersect(m_Player.m_Shots[shot].m_Position,
                                             m_Player.m_Shots[shot].m_Radius))
                        {
                            SetScore();
                            m_Player.m_Shots[shot].Destroy();
                            return(true);
                        }
                    }
                }

                if (m_Player.Active())
                {
                    if (CirclesIntersect(m_Player.m_Position, m_Player.m_Radius))
                    {
                        SetScore();
                        m_Player.Hit();
                        return(true);
                    }
                }
            }

            if (m_Shot.Active())
            {
                if (m_Player.Active())
                {
                    if (m_Shot.CirclesIntersect(m_Player.m_Position, m_Player.m_Radius))
                    {
                        m_Player.Hit();
                        m_Shot.Destroy();
                    }
                }
            }

            return(false);
        }