/*
4
*/
/*
output = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse3/sickhorse3.pde");
outputtxt = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse3/list/list.txt");
output = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse4/sickhorse4.pde");
outputtxt = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse4/list/list.txt");
*/


PrintWriter output;
PrintWriter outputtxt;
void setup() { size(800, 800, P3D);
output = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse4/sickhorse4.pde");
outputtxt = createWriter("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/sickhorse4/list/list.txt");
rect(0,0,1000,1000);
}
int li=0;
int runs=4;

int  brdmp=0;

int  brndpb=0;
int  brdmps=0;


int  brdmp1=0;


int  brdmps1=0;
int  brndpb1=0;

int  brdmp2=0;


int  brdmps2=0;
int  brndpb2=0;

int  brdmp3=0;


int  brdmps3=0;
int  brndpb3=0;




int beanx=0;
int beany=0;

int  crdmp=0;
int  crndpb=0;
int  crdmps=0;


int  crdmp1=0;


int  crdmps1=0;
int  crndpb1=0;
int opt=0;
int  crdmp2=0;


int  crdmps2=0;
int  crndpb2=0;

int  crdmp3=0;


int  crdmps3=0;
int  crndpb3=0;
int  drdmp=0;
int  drndpb=0;
int  drdmps=0;


int  drdmp1=0;


int  drdmps1=0;
int  drndpb1=0;

int  drdmp2=0;


int  drdmps2=0;
int  drndpb2=0;

int  drdmp3=0;


int  drdmps3=0;
int  drndpb3=0;





float mx1=0;
float my1=0;
float mx2=0;
float my2=0;

color ship1=color(200, 0, 0);
color ship2 =color(0, 0, 200);
color shipx1=color(200, 0, 0);
color shipx2 =color(0, 0, 200);
color shipm=color(0, 0, 200);
color shipm1=color(0, 0, 200);
color shipm2=color(0, 0, 200);
color shipm3=color(0, 0, 200);



int swit=0;
int sap=0;
int pop=0;
int shrink=180;
int score=180;   
int score2=200;
int enemyx=0;
int enemyy=0;
int enemyx2=0;
int enemyy2=0;


int enemyx3=0;
int enemyy3=0;
int enemyx23=0;
int enemyy23=0;


int i = 0;

int benemyx=0;
int benemyy=0;
int benemyx2=0;
int benemyy2=0;


int benemyx3=0;
int benemyy3=0;
int benemyx23=0;
int benemyy23=0;



int movet=0;
int run=0;
int cenemyx=0;
int cenemyy=0;
int cenemyx2=0;
int cenemyy2=0;


int cenemyx3=0;
int cenemyy3=0;
int cenemyx23=0;
int cenemyy23=0;
int denemyx=0;
int denemyy=0;
int denemyx2=0;
int denemyy2=0;


int denemyx3=0;
int denemyy3=0;
int denemyx23=0;
int denemyy23=0;

int  rdmp=0;
int  rdmps=0;
int rndpb=0;

int  rdmp1=0;
int  rdmps1=0;
int rndpb1=0;

int  rdmp2=0;
int  rdmps2=0;
int rndpb2=0;

int  rdmp3=0;
int  rdmps3=0;
int rndpb3=0;
int ammo=3;
int defmove=0;
int level=1;
int Chargo=50;
int Target=0;
int Traktor=0;
int Waste=0;
int fit=0;
int hit=0;
int ehit=12;
int shiphit=0;
int laser=0;

void draw(){
  
  
  
 String[] lines = loadStrings("list/list.txt");
  String ggg="//eof";
 String xxx="4";
if (xxx.equals(lines[li]) == true&&li==1 ){outputtxt.println(5);output.println(5);runs=4;li++;}
if (xxx.equals(lines[li]) == false&&li==1 ){outputtxt.println(4);output.println(4);runs=5;li++;}

if (mousePressed&&(ggg.equals(lines[li+1]) == true)){  
output.println(lines[li]);outputtxt.println(lines[li]);
output.println(lines[li+1]);outputtxt.println(lines[li+1]);
 
        output.flush();  // Writes the remaining data to the file
 output.close();
 
        outputtxt.flush();  // Writes the remaining data to the file
 outputtxt.close();
 exit();
}
      
fill(0);
text(lines[li],10,10*li+10);
println(li+lines[li]);

if (ggg.equals(lines[li]) == false ) {
if(runs==4&&li==14){output.println(lines[li-10]);outputtxt.println(lines[li-10]);li++;}else
if(runs==5&&li==14){output.println(lines[li-8]);outputtxt.println(lines[li-8]);li++;}else
if(runs==4&&li==15){outputtxt.println(lines[li-10]);output.println(lines[li-10]);li++;}else
if(runs==5&&li==15){outputtxt.println(lines[li-8]);output.println(lines[li-8]);li++;}else 
{output.println(lines[li]);outputtxt.println(lines[li]);li++;}}
else    { 


output.println(lines[li]);outputtxt.println(lines[li]);
 
        output.flush();  // Writes the remaining data to the file
 output.close();
 
        outputtxt.flush();  // Writes the remaining data to the file
 outputtxt.close();

li=0; fill(255);
rect(0,0,1000,1000);
 if (runs==4){ launch("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/start2.bat");
 exit();}
 else { launch("C:/Users/Jan Bühring/Desktop/Neuer Ordner (11)/processing-3.5.4-windows64/processing-3.5.4/start.bat");
 exit();


}}

  noStroke();
  fill(0);
  // rect(0,0,450,450);

  float  mouseovery2;
  float  mouseoverx2;




  float  mouseovery1;
  float  mouseoverx1;



  mouseovery2 = mouseY;
  mouseoverx2 = mouseX;

  mouseovery1 = mouseY;
  mouseoverx1 = mouseX;



  //stroke(255, 200); // Linienfarbe ist weiss und nicht ganz deckend   
  // Linienbreite zwei Pixel
  smooth();         // Anti-Aliasing einschalten
  //  if ((mouseoverx >= 650 && mouseoverx <= 790) && (mouseovery  >= 50 && mouseovery  <=100)) {//??

  // clear out all the transformations

  // draw another box at the same (x, y, z) coordinate as the other

  mx1=mouseoverx1;
  my1=mouseovery1;

  mx2=mouseoverx2;
  my2=mouseovery2;

  if (ammo<100)ammo=15;

  fill(140, ammo, 255, 050);
  stroke(20, 10+ammo, 200, 050);
  translate(0, 0); 
  strokeWeight(4);

  box(mx2, my2, (mx2+my2)/2);

  //pushMatrix();
  //translate(30, 20);
  //fill(0);  
  //rect(0, 0, 50, 50);  // Black rectangle
  //popMatrix();



  if (movet==1) {


    if (mousePressed && (mouseButton == LEFT)&&pop==1) {

      movet=0;

      if (ship1==get((int)mouseoverx1, (int)mouseovery1)) {


        sap=1;
        shrink++;
        delay(100);
        if (ammo>=180)ammo=175;

        strokeWeight(4);
        stroke(0, 0, 255);
        translate(20, 20, 20);
        line (0, 0, mx1, my1);  
        float winkel;
        float laenge; 
        float dx;  
        float dy;  
        stroke(255, 200);  
        strokeWeight(2);  
        smooth(); 
        i=0;
        while ( i < ammo+Chargo ) { 



          i++;  
          winkel = random(2*PI);    
          laenge = random(min(width/2, height/2));    
          dx = cos(winkel)*laenge;    
          dy = sin(winkel)* laenge; 
          stroke(200, 0, 0, 150);
          line (mx1, my1, 40+score+dx, 40+score+dy);  
          noStroke();
          fill(0);
        }
        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;

        Target++;
        if (Target>=2)Target=2;

        fit=Waste-Target;
        hit=(int)random(1, 6);
        if (hit-fit<=1) {
          hit=1;
          fit=0;
        }
        ammo=ammo-hit-fit;
        laser=hit-fit;
        ehit=ehit-laser;
        if (ehit<=0)movet=0;
        else movet=1;

        Waste=Waste+(int)random(0, 2);
        if (ammo<=0)ammo=0;

        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;


        translate(0, 0); 
        strokeWeight(4);
        stroke(20+ammo, 10, 200, 050+ammo);
        box(mx2, my2, (mx2+my2)/2);

        if (ehit<=0) {
          movet=0;
          ehit=7;
        } else movet=1;
      } else {
        delay(100);
        sap=0;
        shrink--;

        movet=1;

        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;

        Target=Target-(int)random(0, 2);
        if (Target>=2)Target=2;
        if (Target<=0)Target=0;
        fit=Waste-Target;
        hit=(int)random(1, 6);
        if (hit-fit<=1) {
          hit=1;
          fit=0;
        }
        ammo=ammo-hit-fit;
        Waste=Waste-(int)random(0, 2);
        if (ammo<=0)ammo=0;

        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;


        if (ammo>=180)ammo=175;
        strokeWeight(4);
        stroke(0, 0, 255);
        translate(20, 20, 20);
        line (0, 0, mx1, my1);  
        Waste=Waste-(int)random(0, 2);
        if (ammo<0)ammo=0;
        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;
        translate(0, 0); 
        strokeWeight(4);
        stroke(20, 10+ammo, 200, 050+ammo);
        box(mx2, my2, (mx2+my2)/2);
        pop=1;
        sap=1;
      }
    }



    if (mousePressed && (mouseButton == RIGHT)&&pop==1) {
      movet=0;

      if (ship2==get((int)mouseoverx1, (int)mouseovery1)) {
        sap=1;
        shrink++;
        delay(100);
        ammo=ammo+(int)random(Traktor, 12);
        if (ammo>=Chargo)ammo=Chargo;
        strokeWeight(4);
        stroke(255, 0, 0);
        translate(20, 20, 20);
        line (0, 0, mx1, my1); 
        strokeWeight(4);
        stroke(0, 0, 255);
        translate(20, 20, 20);
        line (0, 0, mx1, my1);  
        float winkel;
        float laenge; 
        float dx;  
        float dy;  
        stroke(255, 200);  
        strokeWeight(2);  
        smooth(); 
        i=0;
        while ( i < ammo ) { 



          i++;  
          winkel = random(2*PI);    
          laenge = random(min(width/2, height/2));    
          dx = cos(winkel)*laenge;    
          dy = sin(winkel)* laenge; 
          stroke(0, 0, 255, 150);
          line (dx/5, dy/5, mx1+100, my1+100);  
          //line (mx1, my1, 40+score+dx/2, 40+score+dy/2);  

          noStroke();
          fill(0);
        }




        if (ammo<0)ammo=0;
        Waste=Waste+(int)random(0, 2);

        if (Waste<=1) {
          if (Target>=1)
            Traktor=Traktor+(int)random(0, 2);
        }

        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;




        if (Waste==2) {
          Chargo=Chargo-(int)random(0, 2);
        }
        if (Chargo<=45) {
          if (Waste==2)Traktor=Traktor-(int)random(0, 2);
        }


        Chargo++;
        if (Traktor==10)Traktor=9;
        if (Waste<=0)Waste=0;

        Target=Target+(int)random(0, 2);

        if (Target>=2)Target=2;
        if (Target<=0)Target=0;
        fit=Waste-Target;
        hit=(int)random(1, 6);
        if (hit-fit<=1) {
          hit=1;
          fit=0;
        }
        ammo=ammo-hit-fit;

        if (ammo<=0)ammo=0;

        strokeWeight(4);
        stroke(0, 0, 255);
        translate(20, 20, 20);
        line (0, 0, mx1, my1);  

        stroke(255, 200);  
        strokeWeight(2);  
        smooth(); 
        i=0;
        while ( i < ammo ) { 



          i++;  
          winkel = random(2*PI);    
          laenge = random(min(width/2, height/2));    
          dx = cos(winkel)*laenge;    
          dy = sin(winkel)* laenge; 
          stroke(0, 0, 255, 150);
          line (dx/5, dy/5, mx1+100, my1+100);  
          //line (mx1, my1, 40+score+dx/2, 40+score+dy/2);  

          noStroke();
          fill(0);
        }



        translate(0, 0); 
        strokeWeight(4);
        stroke(20, 10+ammo, 200, 050+ammo);
        box(mx2, my2, (mx2+my2)/2);

        rdmp=0;
        rdmps=0;
        rndpb=0;

        rdmp1=0;
        rdmps1=0;
        rndpb1=0;

        rdmp=2;
        rdmps2=0;
        rndpb2=0;

        rdmp=3;
        rdmps3=0;
        rndpb3=0;



        brdmp=0;
        brdmps=0;
        brndpb=0;

        brdmp1=0;
        brdmps1=0;
        brndpb1=0;

        brdmp=2;
        brdmps2=0;
        brndpb2=0;

        brdmp=3;
        brdmps3=0;
        brndpb3=0;

   crdmp=0;
       crdmps=0;
        crndpb=0;

        crdmp1=0;
        crdmps1=0;
        crndpb1=0;

        crdmp=2;
        crdmps2=0;
        crndpb2=0;

        crdmp=3;
        crdmps3=0;
        crndpb3=0;


        drdmp=0;
        drdmps=0;
        drndpb=0;

        drdmp1=0;
        drdmps1=0;
        drndpb1=0;

        drdmp=2;
        drdmps2=0;
        drndpb2=0;

        drdmp=3;
        drdmps3=0;
        drndpb3=0;

        laser=hit-fit;
        ehit=ehit-laser;
        if (ehit<=0) {
          movet=0;
          ehit=7;
        } else movet=1;
      } else {
        delay(100);
        sap=0;
        shrink--;

        movet=1;
        fit=Waste-Target;
        hit=(int)random(1, 6);
        if (hit-fit<=1) {
          hit=1;
          fit=0;
        }
        ammo=ammo-hit-fit;

        if (ammo>=180)ammo=175;
        if (ammo<0)ammo=0;
        strokeWeight(4);
        stroke(255, 0, 0);
        translate(20, 20, 20);
        line (0, 0, mx1, my1);  
        Waste=Waste-(int)random(0, 1);
        Target=Target-(int)random(0, 2);
        if (Target>=2)Target=2;
        if (Target<=0)Target=0;
        if (Waste>=2)Waste=2;
        if (Waste<=0)Waste=0;
        translate(0, 0); 
        strokeWeight(4);
        stroke(20+ammo, 10, 200, 050+ammo);
        box(mx2, my2, (mx2+my2)/2);
        pop=1;
        sap=1;
      }
    }
  }
  if (run==0) {
    sap=0;
    pop=0;
    run=1;
    movet=0;
  }

  if (sap==0&&pop==0&&movet==0) {
    pop=1;



    int num = (int)random(0, 6);
    int num2 = (int)random(0, 6);
  int num3 = (int)random(0, 6);
    int num4 = (int)random(0, 6);
    
    
    
    switch(num2) {
    case 0:  
      { 
        stroke(ship1);


        benemyx=(int)random(50, 200);
        benemyy=(int)random(50, 200);
        benemyy2=(int)random(50, 200) +300-shrink;
        benemyx2=(int)random(50, 200) +300-shrink;
        
        shipm1=(ship1);


        benemyx3= benemyx;
        benemyy3= benemyy;
        benemyx23= benemyy2;
        benemyy23= benemyx2;



        movet=1;
        ;
      }; 
      break;


    case 1:   
      { 
        stroke(ship2);



        //rect(random(50,200), random(50,200)+200,random(50,200) +200-shrink,random(50,200)+200-shrink );  // Black rectangle

        benemyx=(int)random(50, 200);
        benemyy=(int)random(50, 200);
        benemyy2=(int)random(50, 200) +300-shrink;
        benemyx2=(int)random(50, 200) +300-shrink;
        // Black rectangle


        shipm1=(ship2);
        movet=1;


        benemyx3= benemyx;
        benemyy3= benemyy;
        benemyx23= benemyy2;
        benemyy23= benemyx2;
      };

      break;
    case 2:   
      {
        stroke(ship1);


        benemyx=(int)random(50, 200);
        benemyy=(int)random(50, 200);
        benemyy2=(int)random(50, 200) +300-shrink;
        benemyx2=(int)random(50, 200) +300-shrink;
       

        benemyx3= benemyx;
        benemyy3= benemyy;
        benemyx23= benemyy2;
        benemyy23= benemyx2;
        shipm1=(ship1);
        //(random(50,400)+200,random(50,400),random(50,400) +200-shrink,random(50,400) +200-shrink);  // Black rectangle

        movet=1;
      }; 
      break;
    case 3:   
      {
        stroke(ship2);

        benemyx=(int)random(50, 200);
        benemyy=(int)random(50, 200);
        benemyy2=(int)random(50, 200) +300-shrink;
        benemyx2=(int)random(50, 200) +300-shrink;
         // Black rectangle

        shipm1=(ship2);
        //rect(random(50,200)+200, random(50,200),random(50,200) +200-shrink,random(50,200)+200 -shrink);  // Black rectangle

        benemyx3= benemyx;
        benemyy3= benemyy;
        benemyx23= benemyy2;
        benemyy23= benemyx2;
        movet=1;
      }; 
      break;
    case 4:   
      {   
        stroke(ship1);
        benemyx=(int)random(50, 200);
        benemyy=(int)random(50, 200);
        benemyy2=(int)random(50, 200) +300-shrink;
        benemyx2=(int)random(50, 200) +300-shrink;
  

        shipm1=(ship1);

        benemyx3= benemyx;
        benemyy3= benemyy;
        benemyx23= benemyy2;
        benemyy23= benemyx2;
        movet=1;
        //rect(random(50,200)+200, random(50,200)+200,random(50,200) +200-shrink,random(50,200) +200-shrink);  // Black rectangle
      }; 
      break;
    case 5:   
      {   
        {
          stroke(ship2);

          benemyx=(int)random(50, 200);
          benemyy=(int)random(50, 200);
          benemyy2=(int)random(50, 200) +300-shrink;
          benemyx2=(int)random(50, 200) +300-shrink;
        

          benemyx3= benemyx;
          benemyy3= benemyy;
          benemyx23= benemyy2;
          benemyy23= benemyx2;

          //rect(random(50,200)+200, random(50,200),random(50,200) +200-shrink,random(50,200)+200 -shrink);  // Black rectangle
          shipm1=(ship2);
          movet=1;
        };  
        break;
      }
    }

    switch(num) {
    case 0:  
      { 
        stroke(ship1);


        enemyx=(int)random(50, 300);
        enemyy=(int)random(50, 300);
        enemyy2=(int)random(50, 300) +300-shrink;
        enemyx2=(int)random(50, 300) +300-shrink;
       
        shipm=(ship1);


        enemyx3= enemyx;
        enemyy3= enemyy;
        enemyx23= enemyy2;
        enemyy23= enemyx2;



        movet=1;
        ;
      }; 
      break;


    case 1:   
      { 
        stroke(ship2);



        //rect(random(50,300), random(100,300)+300,random(100,300) +300-shrink,random(100,300)+300-shrink );  // Black rectangle

        enemyx=(int)random(50, 300);
        enemyy=(int)random(50, 300);
        enemyy2=(int)random(50, 300) +300-shrink;
        enemyx2=(int)random(50, 300) +300-shrink;
   


        shipm=(ship2);
        movet=1;


        enemyx3= enemyx;
        enemyy3= enemyy;
        enemyx23= enemyy2;
        enemyy23= enemyx2;
      };

      break;
    case 2:   
      {
        stroke(ship1);


        enemyx=(int)random(50, 300);
        enemyy=(int)random(50, 300);
        enemyy2=(int)random(50, 300) +300-shrink;
        enemyx2=(int)random(50, 300) +300-shrink;
 

        enemyx3= enemyx;
        enemyy3= enemyy;
        enemyx23= enemyy2;
        enemyy23= enemyx2;
        shipm=(ship1);
        //(random(50,400)+300,random(50,400),random(50,400) +300-shrink,random(50,400) +300-shrink);  // Black rectangle

        movet=1;
      }; 
      break;
    case 3:   
      {
        stroke(ship2);

        enemyx=(int)random(50, 300);
        enemyy=(int)random(50, 300);
        enemyy2=(int)random(50, 300) +300-shrink;
        enemyx2=(int)random(50, 300) +300-shrink;
        


        shipm=(ship2);
        //rect(random(50,300)+300, random(50,300),random(50,300) +300-shrink,random(50,300)+300 -shrink);  // Black rectangle

        enemyx3= enemyx;
        enemyy3= enemyy;
        enemyx23= enemyy2;
        enemyy23= enemyx2;
        movet=1;
      }; 
      break;
    case 4:   
      {   
        stroke(ship1);
        enemyx=(int)random(50, 300);
        enemyy=(int)random(50, 300);
        enemyy2=(int)random(50, 300) +300-shrink;
        enemyx2=(int)random(50, 300) +300-shrink;
 

        shipm=(ship1);

        enemyx3= enemyx;
        enemyy3= enemyy;
        enemyx23= enemyy2;
        enemyy23= enemyx2;
        movet=1;
        //rect(random(50,300)+300, random(50,300)+300,random(50,300) +300-shrink,random(50,300) +300-shrink);  // Black rectangle
      }; 
      break;
    case 5:   
      {   
        {
          stroke(ship2);

          enemyx=(int)random(50, 300);
          enemyy=(int)random(50, 300);
          enemyy2=(int)random(50, 300) +300-shrink;
          enemyx2=(int)random(50, 300) +300-shrink;


          enemyx3= enemyx;
          enemyy3= enemyy;
          enemyx23= enemyy2;
          enemyy23= enemyx2;

          //rect(random(50,300)+300, random(50,300),random(50,300) +300-shrink,random(50,300)+300 -shrink);  // Black rectangle
          shipm=(ship2);
          movet=1;
        };  
        break;
      }
    }
  

  //---------------------------------------------------------------------------------------------------0

    switch(num3) {
    case 0:  
      { 
        stroke(ship1);


        cenemyx=(int)random(100, 200);
        cenemyy=(int)random(100, 200);
        cenemyy2=(int)random(100, 200) +300-shrink;
        cenemyx2=(int)random(100, 200) +300-shrink;
 
        shipm3=(ship1);


        cenemyx3= cenemyx;
        cenemyy3= cenemyy;
        cenemyx23= cenemyy2;
        cenemyy23= cenemyx2;



        movet=1;
        ;
      }; 
      break;


    case 1:   
      { 
        stroke(ship2);



        //rect(random(100,200), random(100,200)+200,random(100,200) +200-shrink,random(100,200)+200-shrink );  // Black rectangle

        cenemyx=(int)random(100, 200);
        cenemyy=(int)random(100, 200);
        cenemyy2=(int)random(100, 200) +300-shrink;
        cenemyx2=(int)random(100, 200) +300-shrink;
    


        shipm3=(ship2);
        movet=1;


        cenemyx3= cenemyx;
        cenemyy3= cenemyy;
        cenemyx23= cenemyy2;
        cenemyy23= cenemyx2;
      };

      break;
    case 2:   
      {
        stroke(ship1);


        cenemyx=(int)random(100, 200);
        cenemyy=(int)random(100, 200);
        cenemyy2=(int)random(100, 200) +300-shrink;
        cenemyx2=(int)random(100, 200) +300-shrink;
     

        cenemyx3= cenemyx;
        cenemyy3= cenemyy;
        cenemyx23= cenemyy2;
        cenemyy23= cenemyx2;
        shipm3=(ship1);
        //(random(100,400)+200,random(100,400),random(100,400) +200-shrink,random(100,400) +200-shrink);  // Black rectangle

        movet=1;
      }; 
      break;
    case 3:   
      {
        stroke(ship2);

        cenemyx=(int)random(100, 200);
        cenemyy=(int)random(100, 200);
        cenemyy2=(int)random(100, 200) +300-shrink;
        cenemyx2=(int)random(100, 200) +300-shrink;
     

        shipm3=(ship2);
        //rect(random(100,200)+200, random(100,200),random(100,200) +200-shrink,random(100,200)+200 -shrink);  // Black rectangle

        cenemyx3= cenemyx;
        cenemyy3= cenemyy;
        cenemyx23= cenemyy2;
        cenemyy23= cenemyx2;
        movet=1;
      }; 
      break;
    case 4:   
      {   
        stroke(ship1);
        cenemyx=(int)random(100, 200);
        cenemyy=(int)random(100, 200);
        cenemyy2=(int)random(100, 200) +300-shrink;
        cenemyx2=(int)random(100, 200) +300-shrink;
   

        shipm3=(ship1);

        cenemyx3= cenemyx;
        cenemyy3= cenemyy;
        cenemyx23= cenemyy2;
        cenemyy23= cenemyx2;
        movet=1;
        //rect(random(100,200)+200, random(100,200)+200,random(100,200) +200-shrink,random(100,200) +200-shrink);  // Black rectangle
      }; 
      break;
    case 5:   
      {   
        {
          stroke(ship2);

          cenemyx=(int)random(100, 200);
          cenemyy=(int)random(100, 200);
          cenemyy2=(int)random(100, 200) +300-shrink;
          cenemyx2=(int)random(100, 200) +300-shrink;
       

          cenemyx3= cenemyx;
          cenemyy3= cenemyy;
          cenemyx23= cenemyy2;
          cenemyy23= cenemyx2;

          //rect(random(100,200)+200, random(100,200),random(100,200) +200-shrink,random(100,200)+200 -shrink);  // Black rectangle
          shipm3=(ship2);
          movet=1;
        };  
        break;
      }
    }

    switch(num4) {
    case 0:  
      { 
        stroke(ship1);


        denemyx=(int)random(100, 150);
        denemyy=(int)random(100, 150);
        denemyy2=(int)random(100, 150) +250-shrink;
        denemyx2=(int)random(100, 150) +250-shrink;
    
        shipm=(ship1);


        denemyx3= denemyx;
        denemyy3= denemyy;
        denemyx23= denemyy2;
        denemyy23= denemyx2;



        movet=1;
        ;
      }; 
      break;


    case 1:   
      { 
        stroke(ship2);



        //rect(random(100,150), random(100,150)+150,random(100,150) +150-shrink,random(100,150)+150-shrink );  // Black rectangle

        denemyx=(int)random(100, 150);
        denemyy=(int)random(100, 150);
        denemyy2=(int)random(100, 150) +250-shrink;
        denemyx2=(int)random(100, 150) +250-shrink;
   


        shipm2=(ship2);
        movet=1;


        denemyx3= denemyx;
        denemyy3= denemyy;
        denemyx23= denemyy2;
        denemyy23= denemyx2;
      };

      break;
    case 2:   
      {
        stroke(ship1);


        denemyx=(int)random(100, 150);
        denemyy=(int)random(100, 150);
        denemyy2=(int)random(100, 150) +250-shrink;
        denemyx2=(int)random(100, 150) +250-shrink;
     

        denemyx3= denemyx;
        denemyy3= denemyy;
        denemyx23= denemyy2;
        denemyy23= denemyx2;
        shipm=(ship1);
        //(random(100,400)+150,random(100,400),random(100,400) +150-shrink,random(100,400) +150-shrink);  // Black rectangle

        movet=1;
      }; 
      break;
    case 3:   
      {
        stroke(ship2);

        denemyx=(int)random(100, 150);
        denemyy=(int)random(100, 150);
        denemyy2=(int)random(100, 150) +250-shrink;
        denemyx2=(int)random(100, 150) +250-shrink;
 

        shipm2=(ship2);
        //rect(random(100,150)+150, random(100,150),random(100,150) +150-shrink,random(100,150)+150 -shrink);  // Black rectangle

        denemyx3= denemyx;
        denemyy3= denemyy;
        denemyx23= denemyy2;
        denemyy23= denemyx2;
        movet=1;
      }; 
      break;
    case 4:   
      {   
        stroke(ship1);
        denemyx=(int)random(100, 150);
        denemyy=(int)random(100, 150);
        denemyy2=(int)random(100, 150) +250-shrink;
        denemyx2=(int)random(100, 150) +250-shrink;
    

        shipm2=(ship1);

        denemyx3= denemyx;
        denemyy3= denemyy;
        denemyx23= denemyy2;
        denemyy23= denemyx2;
        movet=1;
        //rect(random(100,150)+150, random(100,150)+150,random(100,150) +150-shrink,random(100,150) +150-shrink);  // Black rectangle
      }; 
      break;
    case 5:   
      {   
        {
          stroke(ship2);

          denemyx=(int)random(100, 150);
          denemyy=(int)random(100, 150);
          denemyy2=(int)random(100, 150) +250-shrink;
          denemyx2=(int)random(100, 150) +250-shrink;
 

          denemyx3= denemyx;
          denemyy3= denemyy;
          denemyx23= denemyy2;
          denemyy23= denemyx2;

          //rect(random(100,150)+150, random(100,150),random(100,150) +150-shrink,random(100,150)+150 -shrink);  // Black rectangle
          shipm2=(ship2);
          movet=1;
        };  
        break;
      }
    }
  }
////+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  if (movet==1) {
  
  if(mouseButton == RIGHT)opt=0;
  if(mouseButton ==LEFT) opt=1; 
  
  
  if(opt==0){
  
  ///////////////////////////////////////////////////////





    rdmp=(int)random(-3, 3);
    rdmps=rdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;

    rdmp1=(int)random(-3, 3);
    rdmps1=rdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(benemyx+benemyx2)/4)+(cenemyx+cenemyx2/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;
    rndpb3=0;

    rdmp2=(int)random(-3, 3);
    rdmps2=rdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rdmp3=(int)random(-3, 3);
    rdmps3=rdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;
    rndpb3=0;
    enemyx= enemyx3+rdmp+rdmps-ammo;
    enemyy=enemyy3+rdmp1+rdmps1+ammo;

    enemyx2= enemyx3+rdmp2+rdmps2-ammo;
    enemyy2=enemyy3+rdmp3+rdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (enemyx<=50+ammo) {
      enemyx3++;
      enemyx3++; 
      rdmps=0;
    }

    if (enemyy>=600-ammo) {
      enemyy3--;
      enemyy3--;
      rdmps1=0;
    }

    if (enemyx>=600-ammo) {
      enemyx3--;
      enemyx3--;
      rdmps=0;
    }

    if (enemyy<=50+ammo) {
      enemyy3++;
      enemyy3++;
      rdmps1=0;
    }



    if (enemyx<=20) {
      enemyx3++;
      enemyx3++;
      rdmps=0;
    }

    if (enemyy+enemyy2>=700) {
      enemyy3--;
      enemyy3--;
      rdmps1=0;
    }

    if (enemyx+enemyx2>=700) {
      enemyx3--;
      enemyx3--;
      rdmps=0;
    }

    if (enemyy<=20) {
      enemyy3++;
      enemyy3++;
      rdmps1=0;
    }


    if ((enemyx2)<=50) {
      enemyx2++;
      enemyx2++;
      rdmps2=0;
    }

    if ((enemyy2)<=50) {
      enemyy2++;
      enemyy2++;
      rdmps3=0;
    }

    if ((enemyx2)>=700) {
      enemyx2--;
      enemyx2--;
      rdmps2=0;
    }

    if ((enemyy2)>=700) {
      enemyy2--;
      enemyy2--;
      rdmps3=0;
    }

    if (abs(enemyx)<100) {
      if (abs(enemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    pop=1;









    brdmp=(int)random(-3, 3);
    brdmps=brdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;

    brdmp1=(int)random(-3, 3);
    brdmps1=brdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;
    brndpb3=0;

    brdmp2=(int)random(-3, 3);
    brdmps2=brdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brdmp3=(int)random(-3, 3);
    brdmps3=brdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;
    brndpb3=0;
    benemyx= benemyx3+brdmp+brdmps-ammo;
    benemyy=benemyy3+brdmp1+brdmps1+ammo;

    benemyx2= benemyx3+brdmp2+brdmps2-ammo;
    benemyy2=benemyy3+brdmp3+brdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (benemyx<=150+ammo) {
      benemyx3++;
      benemyx3++; 
      brdmps=0;
    }

    if (benemyy>=500-ammo) {
      benemyy3--;
      benemyy3--;
      brdmps1=0;
    }

    if (benemyx>=500-ammo) {
      benemyx3--;
      benemyx3--;
      brdmps=0;
    }

    if (benemyy<=150+ammo) {
      benemyy3++;
      benemyy3++;
      brdmps1=0;
    }



    if (benemyx<=120) {
      benemyx3++;
      benemyx3++;
      brdmps=0;
    }

    if (benemyy+benemyy2>=600) {
      benemyy3--;
      benemyy3--;
      brdmps1=0;
    }

    if (benemyx+benemyx2>=600) {
      benemyx3--;
      benemyx3--;
      brdmps=0;
    }

    if (benemyy<=120) {
      benemyy3++;
      benemyy3++;
      brdmps1=0;
    }


    if ((benemyx2)<=50) {
      benemyx2++;
      benemyx2++;
      brdmps2=0;
    }

    if ((benemyy2)<=50) {
      benemyy2++;
      benemyy2++;
      brdmps3=0;
    }

    if ((benemyx2)>=150) {
      benemyx2--;
      benemyx2--;
      brdmps2=0;
    }

    if ((benemyy2)>=150) {
      benemyy2--;
      benemyy2--;
      brdmps3=0;
    }

    if (abs(benemyx)<100) {
      if (abs(benemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }


    crdmp=(int)random(-3, 3);
    crdmps=crdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;

    crdmp1=(int)random(-3, 3);
    crdmps1=crdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2+(denemyy+denemyy2)/5)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2+(denemyx+denemyx2)/5)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2+(denemyy+denemyy2)/5)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;
    crndpb3=0;

    crdmp2=(int)random(-3, 3);
    crdmps2=crdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crdmp3=(int)random(-3, 3);
    crdmps3=crdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;
    crndpb3=0;
    cenemyx= cenemyx3+crdmp+crdmps-ammo;
    cenemyy=cenemyy3+crdmp1+crdmps1+ammo;

    cenemyx2= cenemyx3+crdmp2+crdmps2-ammo;
    cenemyy2=cenemyy3+crdmp3+crdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (enemyx<=50+ammo) {
      cenemyx3++;
      cenemyx3++; 
      crdmps=0;
    }

    if (enemyy>=600-ammo) {
      cenemyy3--;
      cenemyy3--;
      crdmps1=0;
    }

    if (enemyx>=600-ammo) {
      cenemyx3--;
      cenemyx3--;
      crdmps=0;
    }

    if (enemyy<=50+ammo) {
      cenemyy3++;
      cenemyy3++;
      crdmps1=0;
    }



    if (enemyx<=20) {
      cenemyx3++;
      cenemyx3++;
      crdmps=0;
    }

    if (enemyy+enemyy2>=700) {
      cenemyy3--;
      cenemyy3--;
      crdmps1=0;
    }

    if (enemyx+enemyx2>=700) {
      cenemyx3--;
      cenemyx3--;
      crdmps=0;
    }

    if (enemyy<=20) {
      cenemyy3++;
      cenemyy3++;
      crdmps1=0;
    }


    if ((enemyx2)<=50) {
      cenemyx2++;
      cenemyx2++;
      crdmps2=0;
    }

    if ((enemyy2)<=50) {
      cenemyy2++;
      cenemyy2++;
      crdmps3=0;
    }

    if ((enemyx2)>=700) {
      cenemyx2--;
      cenemyx2--;
      crdmps2=0;
    }

    if ((enemyy2)>=700) {
      cenemyy2--;
      cenemyy2--;
      crdmps3=0;
    }

    if (abs(enemyx)<100) {
      if (abs(enemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    pop=1;









    drdmp=(int)random(-3, 3);
    drdmps=drdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;

    drdmp1=(int)random(-3, 3);
    drdmps1=drdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drndpb3=0;
    drndpb3=0;

    drdmp2=(int)random(-3, 3);
    drdmps2=drdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drdmp3=(int)random(-3, 3);
    drdmps3=drdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drndpb3=0;
    drndpb3=0;
    denemyx= denemyx3+drdmp+drdmps-ammo;
    denemyy=denemyy3+drdmp1+drdmps1+ammo;

    denemyx2= denemyx3+drdmp2+drdmps2-ammo;
    denemyy2=denemyy3+drdmp3+drdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (denemyx<=150+ammo) {
      denemyx3++;
      denemyx3++; 
      drdmps=0;
    }

    if (denemyy>=500-ammo) {
      denemyy3--;
      denemyy3--;
      drdmps1=0;
    }

    if (denemyx>=500-ammo) {
      denemyx3--;
      denemyx3--;
      drdmps=0;
    }

    if (denemyy<=150+ammo) {
      denemyy3++;
      denemyy3++;
      drdmps1=0;
    }



    if (denemyx<=120) {
      denemyx3++;
      denemyx3++;
      drdmps=0;
    }

    if (denemyy+denemyy2>=600) {
      denemyy3--;
      denemyy3--;
      drdmps1=0;
    }

    if (denemyx+denemyx2>=600) {
      denemyx3--;
      denemyx3--;
      drdmps=0;
    }

    if (denemyy<=120) {
      denemyy3++;
      denemyy3++;
      drdmps1=0;
    }


    if ((denemyx2)<=50) {
      denemyx2++;
      denemyx2++;
      drdmps2=0;
    }

    if ((denemyy2)<=50) {
      denemyy2++;
      denemyy2++;
      drdmps3=0;
    }

    if ((denemyx2)>=150) {
      denemyx2--;
      denemyx2--;
      drdmps2=0;
    }

    if ((denemyy2)>=150) {
      denemyy2--;
      denemyy2--;
      drdmps3=0;
    }

    if (abs(denemyx)<100) {
      if (abs(denemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    fill(shipm);
    rect(abs(benemyx), abs(benemyy), abs(benemyx2), abs(benemyy2));
    fill(shipm1);
    rect(abs(enemyx), abs(enemyy), abs(enemyx2), abs(enemyy2)); 
   if(runs==4){fill(shipm2);
    rect(abs(cenemyx), abs(cenemyy), abs(cenemyx2), abs(cenemyy2));}
      if(runs==5){fill(shipm3);
    rect(abs(denemyx), abs(denemyy), abs(denemyx2), abs(denemyy2)); }

    pop=1;
  }///////////////////////////////////////
if(opt==1){





    rdmp=(int)random(-3, 3);
    rdmps=rdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;

    rdmp1=(int)random(-3, 3);
    rdmps1=rdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(benemyx+benemyx2)/4)+(cenemyx+cenemyx2/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;
    rndpb3=0;

    rdmp2=(int)random(-3, 3);
    rdmps2=rdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rdmp3=(int)random(-3, 3);
    rdmps3=rdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+(cenemyx+cenemyx2)/3+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(cenemyx+cenemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(benemyy+benemyy2)/4+(cenemyy+cenemyy2)/3)))))*level)))))/1)*rdmp;
    rndpb3=0;
    rndpb3=0;
    enemyx= enemyx3+rdmp+rdmps-ammo;
    enemyy=enemyy3+rdmp1+rdmps1+ammo;

    enemyx2= enemyx3+rdmp2+rdmps2-ammo;
    enemyy2=enemyy3+rdmp3+rdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (enemyx<=50+ammo) {
      enemyx3++;
      enemyx3++; 
      rdmps=0;
    }

    if (enemyy>=600-ammo) {
      enemyy3--;
      enemyy3--;
      rdmps1=0;
    }

    if (enemyx>=600-ammo) {
      enemyx3--;
      enemyx3--;
      rdmps=0;
    }

    if (enemyy<=50+ammo) {
      enemyy3++;
      enemyy3++;
      rdmps1=0;
    }



    if (enemyx<=20) {
      enemyx3++;
      enemyx3++;
      rdmps=0;
    }

    if (enemyy+enemyy2>=700) {
      enemyy3--;
      enemyy3--;
      rdmps1=0;
    }

    if (enemyx+enemyx2>=700) {
      enemyx3--;
      enemyx3--;
      rdmps=0;
    }

    if (enemyy<=20) {
      enemyy3++;
      enemyy3++;
      rdmps1=0;
    }


    if ((enemyx2)<=50) {
      enemyx2++;
      enemyx2++;
      rdmps2=0;
    }

    if ((enemyy2)<=50) {
      enemyy2++;
      enemyy2++;
      rdmps3=0;
    }

    if ((enemyx2)>=700) {
      enemyx2--;
      enemyx2--;
      rdmps2=0;
    }

    if ((enemyy2)>=700) {
      enemyy2--;
      enemyy2--;
      rdmps3=0;
    }

    if (abs(enemyx)<100) {
      if (abs(enemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    pop=1;









    brdmp=(int)random(-3, 3);
    brdmps=brdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;

    brdmp1=(int)random(-3, 3);
    brdmps1=brdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;
    brndpb3=0;

    brdmp2=(int)random(-3, 3);
    brdmps2=brdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brdmp3=(int)random(-3, 3);
    brdmps3=brdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4))))*2), abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*2, abs((((abs((benemyx+benemyx2)/2-(int)mouseoverx1+(enemyx+enemyx2)/4)+abs((benemyy+benemyy2)/2-(int)mouseovery1+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;
    brndpb3=0;
    benemyx= benemyx3+brdmp+brdmps-ammo;
    benemyy=benemyy3+brdmp1+brdmps1+ammo;

    benemyx2= benemyx3+brdmp2+brdmps2-ammo;
    benemyy2=benemyy3+brdmp3+brdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (benemyx<=150+ammo) {
      benemyx3++;
      benemyx3++; 
      brdmps=0;
    }

    if (benemyy>=500-ammo) {
      benemyy3--;
      benemyy3--;
      brdmps1=0;
    }

    if (benemyx>=500-ammo) {
      benemyx3--;
      benemyx3--;
      brdmps=0;
    }

    if (benemyy<=150+ammo) {
      benemyy3++;
      benemyy3++;
      brdmps1=0;
    }



    if (benemyx<=120) {
      benemyx3++;
      benemyx3++;
      brdmps=0;
    }

    if (benemyy+benemyy2>=600) {
      benemyy3--;
      benemyy3--;
      brdmps1=0;
    }

    if (benemyx+benemyx2>=600) {
      benemyx3--;
      benemyx3--;
      brdmps=0;
    }

    if (benemyy<=120) {
      benemyy3++;
      benemyy3++;
      brdmps1=0;
    }


    if ((benemyx2)<=50) {
      benemyx2++;
      benemyx2++;
      brdmps2=0;
    }

    if ((benemyy2)<=50) {
      benemyy2++;
      benemyy2++;
      brdmps3=0;
    }

    if ((benemyx2)>=150) {
      benemyx2--;
      benemyx2--;
      brdmps2=0;
    }

    if ((benemyy2)>=150) {
      benemyy2--;
      benemyy2--;
      brdmps3=0;
    }

    if (abs(benemyx)<100) {
      if (abs(benemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }


    crdmp=(int)random(-3, 3);
    crdmps=crdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;

    crdmp1=(int)random(-3, 3);
    crdmps1=crdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2+(denemyy+denemyy2)/5)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2+(denemyx+denemyx2)/5)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2+(denemyy+denemyy2)/5)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;
    crndpb3=0;

    crdmp2=(int)random(-3, 3);
    crdmps2=crdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crdmp3=(int)random(-3, 3);
    crdmps3=crdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3))))*2), abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*2, abs((((abs((cenemyx+cenemyx2)/2-(int)mouseoverx1-(enemyx+enemyx2)/4+(denemyx+denemyx2)/3)+abs((enemyy+enemyy2)/2-(int)mouseovery1-(cenemyy+cenemyy2)/4+(denemyy+denemyy2)/3)))))*level)))))/1)*rdmp;
    crndpb3=0;
    crndpb3=0;
    cenemyx= cenemyx3+crdmp+crdmps-ammo;
    cenemyy=cenemyy3+crdmp1+crdmps1+ammo;

    cenemyx2= cenemyx3+crdmp2+crdmps2-ammo;
    cenemyy2=cenemyy3+crdmp3+crdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (enemyx<=50+ammo) {
      cenemyx3++;
      cenemyx3++; 
      crdmps=0;
    }

    if (enemyy>=600-ammo) {
      cenemyy3--;
      cenemyy3--;
      crdmps1=0;
    }

    if (enemyx>=600-ammo) {
      cenemyx3--;
      cenemyx3--;
      crdmps=0;
    }

    if (enemyy<=50+ammo) {
      cenemyy3++;
      cenemyy3++;
      crdmps1=0;
    }



    if (enemyx<=20) {
      cenemyx3++;
      cenemyx3++;
      crdmps=0;
    }

    if (enemyy+enemyy2>=700) {
      cenemyy3--;
      cenemyy3--;
      crdmps1=0;
    }

    if (enemyx+enemyx2>=700) {
      cenemyx3--;
      cenemyx3--;
      crdmps=0;
    }

    if (enemyy<=20) {
      cenemyy3++;
      cenemyy3++;
      crdmps1=0;
    }


    if ((enemyx2)<=50) {
      cenemyx2++;
      cenemyx2++;
      crdmps2=0;
    }

    if ((enemyy2)<=50) {
      cenemyy2++;
      cenemyy2++;
      crdmps3=0;
    }

    if ((enemyx2)>=700) {
      cenemyx2--;
      cenemyx2--;
      crdmps2=0;
    }

    if ((enemyy2)>=700) {
      cenemyy2--;
      cenemyy2--;
      crdmps3=0;
    }

    if (abs(enemyx)<100) {
      if (abs(enemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    pop=1;









    drdmp=(int)random(-3, 3);
    drdmps=drdmps+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    brndpb3=0;

    drdmp1=(int)random(-3, 3);
    drdmps1=drdmps1+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drndpb3=0;
    drndpb3=0;

    drdmp2=(int)random(-3, 3);
    drdmps2=drdmps2+((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drdmp3=(int)random(-3, 3);
    drdmps3=drdmps3+ ((int)random(- (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4))))*2), abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))/1))*level)))), (int)sqrt(score2*abs((int)sqrt((int)random(-1*abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*2, abs((((abs((denemyx+denemyx2)/2-(int)mouseoverx1*2+(enemyx+enemyx2)/4)+abs((denemyy+denemyy2)/2-(int)mouseovery1*2+(enemyy+enemyy2)/4)))))*level)))))/1)*rdmp;
    drndpb3=0;
    drndpb3=0;
    denemyx= denemyx3+drdmp+drdmps-ammo;
    denemyy=denemyy3+drdmp1+drdmps1+ammo;

    denemyx2= denemyx3+drdmp2+drdmps2-ammo;
    denemyy2=denemyy3+drdmp3+drdmps3+ammo;

    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);



    stroke(shipm);

    // Black rectangle
    noStroke();
    fill(0);
    rect(0, 0, 800, 800);

    fill(shipm);

    if (denemyx<=150+ammo) {
      denemyx3++;
      denemyx3++; 
      drdmps=0;
    }

    if (denemyy>=500-ammo) {
      denemyy3--;
      denemyy3--;
      drdmps1=0;
    }

    if (denemyx>=500-ammo) {
      denemyx3--;
      denemyx3--;
      drdmps=0;
    }

    if (denemyy<=150+ammo) {
      denemyy3++;
      denemyy3++;
      drdmps1=0;
    }



    if (denemyx<=120) {
      denemyx3++;
      denemyx3++;
      drdmps=0;
    }

    if (denemyy+denemyy2>=600) {
      denemyy3--;
      denemyy3--;
      drdmps1=0;
    }

    if (denemyx+denemyx2>=600) {
      denemyx3--;
      denemyx3--;
      drdmps=0;
    }

    if (denemyy<=120) {
      denemyy3++;
      denemyy3++;
      drdmps1=0;
    }


    if ((denemyx2)<=50) {
      denemyx2++;
      denemyx2++;
      drdmps2=0;
    }

    if ((denemyy2)<=50) {
      denemyy2++;
      denemyy2++;
      drdmps3=0;
    }

    if ((denemyx2)>=150) {
      denemyx2--;
      denemyx2--;
      drdmps2=0;
    }

    if ((denemyy2)>=150) {
      denemyy2--;
      denemyy2--;
      drdmps3=0;
    }

    if (abs(denemyx)<100) {
      if (abs(denemyy)<160) {
        ammo--; 
        if (ammo<=0) {
          shrink--;
        }
      }
    }

    fill(shipm);
    rect(abs(benemyx), abs(benemyy), abs(benemyx2), abs(benemyy2));
    fill(shipm1);
    rect(abs(enemyx), abs(enemyy), abs(enemyx2), abs(enemyy2)); 
  if(runs==4) {fill(shipm2);
    rect(abs(cenemyx), abs(cenemyy), abs(cenemyx2), abs(cenemyy2));}
    if(runs==5){ fill(shipm3);
    rect(abs(denemyx), abs(denemyy), abs(denemyx2), abs(denemyy2)); }

    pop=1;
  }}


  //delay(140);
  if (run==1) {
    sap=1;
    run=2;
    pop=0;
  }

  if (sap==1) {
    noStroke();
    fill(0);
    rect(00, 400, 400, 400);
    noStroke();
    fill(0);
    rect(400, 00, 400, 400);

    noStroke();
    fill(0);
    rect(400, 400, 400, 400);

    sap=0;
    pop=0;
  }












   score=score+(int)random(-2, 2);
if (score<=-1)score++;
if (score<=-9)score=-6;
if (score>=100)score--;
  score2=shrink-score;
  fill(0);
  rect(0, 740, 380, 200);

  fill(255);
  text("Score: "+score2+"/100", 10, 765);
  text("Chargo: "+Chargo, 10, 785);
  text("Target: "+Target+"/2", 110, 765);
  text("Traktor: "+Traktor+"/12", 110, 785);
  text("Waste: "+Waste+"/2", 210, 765);

  text("Force: "+ammo+"/"+Chargo, 210, 785);
  text("Level: "+level, 310, 765);

  //fill(ship1);
  // rect(120,970,30,30);



  if (shrink==280) {  
    ehit=7+level;
    float winkel;
    float laenge; 
    float dx;  
    float dy;     
    stroke(255, 200);  
    strokeWeight(2);  
    smooth(); 
    level++;
    Chargo=Chargo+10*level;


    shrink=180;
    i=0;
    sap=0;
    pop=0;
    run=0;
    movet=0;
    while ( i < 600 ) { 



      i++;  
      winkel = random(2*PI);    
      laenge = random(min(width/2, height/2));    
      dx = cos(winkel)*laenge;    
      dy = sin(winkel)* laenge; 
      stroke(200, 0, 0, 150);
      line (width/2, height/2, width/2+dx, height/2-dy);  
      noStroke();
      fill(0);
    }
    rect(0, 0, 800, 800);
  }
  sap=0;




  if (score2<=-10) {  
    shrink=180;

    fill(255);
    rect(0, 0, 800, 800);

    fill(0);
    text("You Are Destroid!", 400, 400);
    delay(1000); 
    level--;
    if (level<=1)level=1;
    sap=0;
    pop=0;
    run=0;
    movet=0;
    score2 =0;
  } else
    sap=0;





}
//eof
