[Home]TimeToHit

Robo Home | Changes | Preferences | AllPages

Difference (from prior major revision) (no other diffs)

Changed: 7c7
return normalRelativeAngleDiff?(enemyBearing,gunHeading)/20+enemyDistance/(20 - 3 * bulletPower);
return Math.abs(normalRelativeAngleDiff?(enemyBearing,gunHeading))/20+enemyDistance/(20 - 3 * bulletPower);

Changed: 11c11
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.
The first part
Math.abs(normalRelativeAngleDiff(enemyBearing,gunHeading))/20
calculates time needed to rotate the gun, and the second one
enemyDistance/(20 - 3 * bulletPower)
computes bullet travel time.

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 Math.abs(normalRelativeAngleDiff(enemyBearing,gunHeading))/20+enemyDistance/(20 - 3 * bulletPower);
}

The first part

Math.abs(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 text of this page | View other revisions
Last edited July 1, 2004 11:40 EST by Ph (diff)
Search: