mardi 29 septembre 2015

Trying to refine several if statements down

I'm trying to find a more elegant way to reduce my if statements down, what I have right now is a little messy and I reckon could be done better, any suggestions?

        if(ship.position.y >= transform.position.y + yBound)
        {
            hitBounds = true;
        }
        if(ship.position.y <= transform.position.y - yBound)
        {
            hitBounds = true;
        }
        if(ship.position.x >= transform.position.x + xBound)
        {
            hitBounds = true;
        }
        if(ship.position.x <= transform.position.x - xBound)
        {
            hitBounds = true;
        }

Thanks for your time!

Aucun commentaire:

Enregistrer un commentaire