CODERALLY - hitting opponent with tires

Discussion in 'Mac Programming' started by neelvaka, Oct 26, 2007.

  1. macrumors newbie

    Joined:
    Sep 15, 2007
    #1
    yup yup fnny i no

    but those familiar to coderally
    im trying to hit cars with the most efficient way and the rite angle and direction the car is in when an opponent gets an x ammount away from me.

    i have this so far:

    Code:
    if (getDistanceTo(getNearestOpponent()) <= 100) {
                	 throwSpareTire();
                 }
    ...
    ...
    ...
    ...
    
    IObject getNearestOpponent() {
                double minDistance = 1000000, distance;
                IObject theNearestOneO = null;
                for (int f = 0; f < Opponents.length; f++) {
                        distance = getDistanceTo(Opponents[f]);
                        if (distance < minDistance) {
                                minDistance = distance;
                                theNearestOneO = Opponents[f];
                        }
                }
                return theNearestOneO;
        }
    help?
     

Share This Page