Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.74 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. package t1;
  2. import robocode.*;
  3. public class Test1 extends Robot
  4. {
  5.         public void run() {
  6.                 // Initialization of the robot should be put here
  7.  
  8.                 // After trying out your robot, try uncommenting the import at the top,
  9.                 // and the next line:
  10.  
  11.                 // setColors(Color.red,Color.blue,Color.green); // body,gun,radar
  12.  
  13.                 // Robot main loop
  14.                 while(true) {
  15.                         //moveSquare();
  16.                         moveOcto(10);
  17.                 }
  18.         }
  19.  
  20.         public void onScannedRobot(ScannedRobotEvent e) {
  21.                 fire(1);
  22.         }
  23.  
  24.         private void moveSquare() {
  25.        ahead(100);
  26.        turnRight(90);;
  27.                 //Roboter fährt 100 vor und dreht sich 90° nach rechts.
  28.         }
  29.         private void moveOcto(double side) {
  30.                 ahead(side);
  31.                 turnRight(360/8);
  32.                 //Roboter fährt "side" vor und dreht sich 360/8°...
  33.         }
  34. }