Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class AdjustableHoodBot {
- public static void main(String[] args) {
- //Instances
- Random gen = new Random();
- //Variables
- double x,y,height,width;
- double[] wantx = new double[2];
- double LeftMotor = 0, RightMotor = 0;
- double hoodangle = 0, wanthoodangle, distanceh, distancew, heightofgoal;
- boolean auto = false;
- boolean[] good = new boolean[2];
- int testdisth = 0, testheighth = 0;
- int testdistw = 0, testheightw = 0;
- //Create Data
- x = gen.nextInt(640);
- y = gen.nextInt(400);
- height = gen.nextInt(400);
- width = gen.nextInt(640);
- heightofgoal = 88; //Probably should be Minus the height of the shooter
- wantx[0] = 0; // Big
- wantx[1] = 0; // Small
- //Y-Axis of the Target
- //Angle Adjust
- distanceh=((height*testdisth)/testheighth);
- //distancew=((width*testdistw)/testheightw);
- wanthoodangle = Math.atan2(heightofgoal,distanceh);
- if(wanthoodangle > hoodangle){
- //Move hood down
- //Make Code to Take care of this if only ran once
- }
- else if(wanthoodangle < hoodangle){
- //Move hood up
- //Make Code to Take Care of this if only ran once
- }
- else if(wanthoodangle == hoodangle){
- //Hood is Good
- good[0] = true;
- }
- //X-Axis of the Target
- //Differs Depending on Has Turret or Not
- if(wantx[0] < x){
- //Turn with Controller so that it doesn't turn too far
- }
- else if(wantx[1] > x){
- //Turn with Controller so that it doesn't turn too far
- }
- else if(wantx[0] <= x && x >= wantx[1]){
- //good
- good[1] = true;
- }
- //Check if all is good
- if(good[0] && good[1]){
- //Shoot Ball if Trigger is Held
- }
- else{
- //Repeat Code But Shouldnt Need to.
- }
- System.out.println("LeftMotor: "+LeftMotor+" RightMotor: "+RightMotor);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement