lundi 24 avril 2017

How can I create an If statement with three conditions?

I am making a projectile motion simulator and it has to calculate whether the projectile clears an obstacle at an arbitrary distance and height away. The wall occurs at 225 m and has a user determined height.

I have an if statement currently that determines whether the path of the projectile collides with the wall. The interval at which the path (pt1) is being draw is calculated based on the total flight time of the projectile. That being said I can't simply use "else if (pt1 == 225)....." because pt1 never is exactly 225 ( the location of the wall).

else if ((pt2 >= (210 - m_wall)) && (pt1 >= 224)){
        m_display = "The Wall has be struck! :/";
        UpdateData(false);
        break;
    }

The problem the program passes the check initially but gets caught on the other side of the wall where the conditions are met again.

I would like to add a third condition to my if statement. For example:

else if ((pt2 >= (210 - m_wall)) && (pt1 >= 224) && (pt1 <= 227)){

...... }

Aucun commentaire:

Enregistrer un commentaire