[Home]TimeToHit

Robo Home | Changes | Preferences | AllPages

Showing revision 2
Time needed to rotate the gun (Targeting) and bullet travel time.

Sample code:

public static double timeToHit(double enemyBearing, double enemyDistance, double gunHeading, double bulletPower) {
    return normalRelativeAngleDiff(enemyBearing,gunHeading)/20+enemyDistance/(20 - 3 * bulletPower);
}

The first part

normalRelativeAngleDiff(enemyBearing,gunHeading)/20
calculates time needed to rotate the gun, and the second one
enemyDistance/(20 - 3 * bulletPower)
computes bullet travel time.

Robo Home | Changes | Preferences | AllPages
Edit revision 2 of this page | View other revisions | View current revision
Edited June 2, 2004 14:07 EST by Ph (diff)
Search: