Tuesday, 22 November 2011

automated robot

import edu.dat.*;
import edu.dat.HeavyTankRobot;

/**
@author tpiercey
**/


public class AutomatedTank extends HeavyTankRobot {

//set up for robot tank, string tank image and ip to class 

 public static void main(String[] args) {
    AutomatedTank Abot = new AutomatedTank ("127.0.0.1","http://images.wikia.com/gtawiki/images/4/41/Tank-GTA2.png"); 
 }

//loop set up with radar detection, width set to a 180 degree angle with front postion for Beam Direction

 public AutomatedTank (String ip,String url){
super (ip,url);
while(true){
forward();{
  if (this.getSpeed()==0)
  {this.forwardGear();}
  this.accelerate();
}
   
Collision();{
  if(this.isTouchingWall());
  for(int i=1; i<=15; i++){
  this.turnLeft();
  this.forwardGear();
  this.accelerate();
  }
}
 
fire();{
    this.setRadarBeamDirection(0);
    this.setRadarBeamWidth(180);
    if (this.ping() != -1) this.fire();
}
 
 
 
}

 

 
 }  

   
   
//setting tank speed to engage forwards

   public void forward(){
  if (this.getSpeed()==0)
  {this.forwardGear();}
  this.accelerate();  
   }
   


   //Method made for If touching wall
   public void Collision(){
   
//rotates tank by 15 and engages accelerate
  for(int i=1; i<=15; i++){
  if (this.isTouchingWall());
  this.decelerate();
  this.turnLeft();
  this.forwardGear();
  this.accelerate();
  }}

   //Method made for shooting
   public void fire(){
  this.setRadarBeamDirection(0);
  this.setRadarBeamWidth(180);
  if (this.ping() != -1) this.fire();
   }
}


 
   









No comments:

Post a Comment