/* * ---------------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * <martinv@students.zcu.cz> wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Martin VĂtek * ---------------------------------------------------------------------------------- */ package cz.zcu.martinv.MyRobocodeRobots; import robocode.*; import java.awt.event.KeyEvent; /** * Very simple bot * * @author martin.vitek */ public class FirstBot extends Robot { public void run() { out.format("Hi, I'm Fred%n"); while(true) { for (int i=0; i<4; i++) { //ahead(100); //turnRight(90); turnRadarRight(10); } } } public void onScannedRobot(ScannedRobotEvent e) { turnGunLeft(/*getGunHeading()+*/(180.0-e.getHeading())); fire(3); out.format("Name: %s\tBearing: %f\u00B0%n", e.getName(), e.getBearing()); } public void onKeyPressed(KeyEvent e) { out.format("Key: %d%n", e.getKeyCode()); } }