Guest User

Untitled

a guest
Jun 24th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package ff;
  2. import robocode.Robot;
  3. import robocode.ScannedRobotEvent;
  4. import java.awt.*;
  5. import robocode.WinEvent;
  6.  
  7. /**
  8. * Verbal - a robot by Fredrik F.
  9. */
  10. public class Verbal extends Robot
  11. {
  12. /**
  13. * run: Verbal's default behavior
  14. */
  15. public void run() {
  16. // After trying out your robot, try uncommenting the import at the top,
  17. // and the next line:
  18. setBodyColor(Color.black);
  19. setGunColor(Color.yellow);
  20. setBulletColor(Color.red);
  21. setRadarColor(Color.blue);
  22. setScanColor(Color.green);
  23.  
  24. while(true) {
  25. // Replace the next 4 lines with any behavior you would like
  26. turnBodyLeft(45);
  27. }
  28. }
  29.  
  30. /**
  31. * onScannedRobot: What to do when you see another robot
  32. */
  33. public void onScannedRobot(ScannedRobotEvent e) {
  34. fire(1);
  35. }
  36.  
  37. /**
  38. * onHitByBullet: What to do when you're hit by a bullet
  39. */
  40. public void onHitByBullet(HitByBulletEvent e) {
  41. turnLeft(90 - e.getBearing());
  42.  
  43. }
  44.  
  45. public void onWin(WinEvent e) {
  46. turnLeft(36000);
  47. }
  48. }
Add Comment
Please, Sign In to add comment