
Untitled
By: a guest on Jan 28th, 2012 | syntax:
None | size: 0.74 KB | hits: 14 | expires: Never
package t1;
import robocode.*;
public class Test1 extends Robot
{
public void run() {
// Initialization of the robot should be put here
// After trying out your robot, try uncommenting the import at the top,
// and the next line:
// setColors(Color.red,Color.blue,Color.green); // body,gun,radar
// Robot main loop
while(true) {
//moveSquare();
moveOcto(10);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
fire(1);
}
private void moveSquare() {
ahead(100);
turnRight(90);;
//Roboter fährt 100 vor und dreht sich 90° nach rechts.
}
private void moveOcto(double side) {
ahead(side);
turnRight(360/8);
//Roboter fährt "side" vor und dreht sich 360/8°...
}
}