Difference between revisions of "Module/Radar/WideLock"
Jump to navigation
Jump to search
(Module Radar WideLock) |
RednaxelaBot (talk | contribs) m (Using <syntaxhighlight>.) |
||
Line 1: | Line 1: | ||
− | < | + | <syntaxhighlight> |
package jab.radar; | package jab.radar; | ||
Line 41: | Line 41: | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
Latest revision as of 09:29, 1 July 2010
package jab.radar;
import jab.Module;
import jab.Radar;
import robocode.Event;
import robocode.ScannedRobotEvent;
import robocode.util.Utils;
/**
* Credits
* RadarBot by PEZ
*/
public class WideLock extends Radar {
public WideLock(Module bot) {
super(bot);
}
private int timeSinceLastScan = 10;
private double enemyAbsoluteBearing;
public void scan(){
timeSinceLastScan++;
double radarOffset = Double.NEGATIVE_INFINITY;
if (timeSinceLastScan < 3) {
radarOffset = Utils
.normalRelativeAngle(bot.getRadarHeadingRadians()
- enemyAbsoluteBearing);
radarOffset += Math.signum(radarOffset) * 0.2;
}
bot.setTurnRadarLeftRadians(radarOffset);
}
public void listen(Event e){
if (e instanceof ScannedRobotEvent){
enemyAbsoluteBearing = bot.getHeadingRadians() + bot.enemy.bearingRadians;
timeSinceLastScan = 0;
}
}
}