package com.gshs;import robocode.*;public class Gshs_21043 extends Robot{ public void run() { while(true) { turnRadarRight(90); } } public void onScannedRobot(ScannedRobotEvent e) { turnRight(e.getBearing()); fire(3); ahead(e.getDistance()); } public void onHitByBullet(HitByBulletEvent e) { // Replace the next line with any behavior you would like back(10); } public void onHitWall(HitWallEvent e) { // Replace the next line with any behavior you would like back(20); } }
In onScannedRobot, I wrote fire(3) then ahead, but when I build and run, when my robot scans the target robot, it runs towards the target, and when it arrives there, my robot shoots.
It acts just like the two lines are switched, so I tried switching two lines just in case, but this didn't work. Can anyone tell me what is wrong?