You are on page 1of 3

package Test2;

import robocode.*;
import java.awt.Color;

// API help : https://robocode.sourceforge.io/docs/robocode/robocode/Robot.html

/**
* Robotel - a robot by (your name here)
*/
public class Robotel extends Robot
{public boolean agressiv=true;
/**
* run: Robotel's default behavior
*/
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:
System.out.println("Numele meu este:RoboDragos si am fost creat pentru
a distrugere");
setColors(Color.red,Color.yellow,Color.blue); // body,gun,radar

// Robot main loop


//6.1
/* ahead(150);
turnRight(90);
ahead(150);
turnRight(90);
ahead(150);
turnRight(90);
ahead(150);
*/

//6.2
/*
for(int i=0;i<10;i++){
ahead(150);
turnRight(90);
ahead(150);
turnRight(90);
ahead(150);
turnRight(90);
ahead(150);
turnRight(90);
}
*/

//6.3
/* int j=0;
int k=0;
for(int i=0;i<10;i++){
while(j<4){
ahead(150);
turnRight(90);
j++;
}j=0;

}*/
//6.4
/* while(true){
ahead(150);
turnRight(90);
}
*/
//6.5
/*int j=0;
int k=0;
for(int i=0;i<10;i++){
while(j<4){
ahead(150);
turnRight(90);
j++;}
j=0;k++;
}
System.out.println("Number of squares in one round are:"+k);
*/
//6.6
int j=0;
int x=0;
while(true){
if(x%2==0){
while(j<4){
ahead(150);
turnRight(90);

j++;}
j=0;
turnRight(90);x++;
}
else{
while(j<4){
ahead(150);
turnLeft(90);

j++;}
j=0;x++;turnLeft(90);
}}

//moveInSquare(150);
}
//6.7
public void moveInSquare(int lengthOfSide){
int j=0;
int k=0;
for(int i=0;i<10;i++){
while(j<4){
ahead(lengthOfSide);
turnRight(90);
j++;}
j=0;k++;
}
System.out.println("Number of squares in one round are:"+k);
}
public void onScannedRobot(ScannedRobotEvent event){
if(event.getDistance()<200){
System.out.println("#############################");
System.out.println("Atentie se apropie!!!");
System.out.println("Numele robotului: "+event.getName());
System.out.println("Energia pe care o mai are este
de :"+event.getEnergy());
System.out.println("Distanta acestuia fata de robotul meu :
"+event.getDistance());
fire(1);
}
if(event.getDistance()<150&&this.agressiv==true){
System.out.println("Sunt furios!!!");
setColors(Color.red,Color.red,Color.red);
fire(1);
this.agressiv=false;}
else
{if(event.getDistance()>150&&this.agressiv==false)
{
System.out.println("Te-am iertat!!!");

setColors(Color.yellow,Color.yellow,Color.yellow);
this.agressiv=true;
}
}

}
public void onBulletHit(BulletHitEvent event){
System.out.println("Am produs avarii tancului");
}
public void onRoundEnded(RoundEndedEvent event) {
out.println("Am castigat runda!!!!!");
turnGunRight(360);
turnLeft(360);
}

You might also like