daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     /**
  3.      * onScannedRobot:  Here's the good stuff
  4.      */
  5.     public void onScannedRobot(ScannedRobotEvent e) {
  6.  
  7.         // If we have a target, and this isn't it, return immediately
  8.         // so we can get more ScannedRobotEvents.
  9.         if (trackName != null && !e.getName().equals(trackName)) {
  10.             return;
  11.         }
  12.  
  13.         // If we don't have a target, well, now we do!
  14.         if (trackName == null) {
  15.             trackName = e.getName();
  16.             out.println("Tracking " + trackName);
  17.         }
  18.         // This is our target.  Reset count (see the run method)
  19.         count = 0;
  20.         // If our target is too far away, turn and move toward it.
  21.         if (e.getDistance() > 150) {
  22.             gunTurnAmt = normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading()));
  23.  
  24.             turnGunRight(gunTurnAmt); // Try changing these to setTurnGunRight,
  25.             turnRight(e.getBearing()); // and see how much Tracker improves...
  26.             // (you'll have to make Tracker an AdvancedRobot)
  27.             ahead(e.getDistance() - 140);
  28.             return;
  29.         }
  30.  
  31.         // Our target is close.
  32.         gunTurnAmt = normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading()));
  33.         turnGunRight(gunTurnAmt);
  34.         fire(3);
  35.  
  36.         // Our target is too close!  Back up.
  37.         if (e.getDistance() < 100) {
  38.             if (e.getBearing() > -90 && e.getBearing() <= 90) {
  39.                 back(40);
  40.             } else {
  41.                 ahead(40);
  42.             }
  43.         }
  44.         scan();
  45.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top