//Tie Fighter Air Battle by Adam Quesnel //Move mouse around to move the X-Wing Target //When target is in the middle of the Tie Fighter ships middle window left/right click on the mouse to shoot lasers. //A red HUD will show once the X-Wing target is in range to fire at. void setup() { size(400, 400); } void draw(){ frameRate(120); background(50); //Stars Background stroke(255); strokeWeight(7); point(350+mouseX/80,205-mouseY/9); point(305+mouseX/80,130-mouseY/9); point(200+mouseX/80,230-mouseY/9); point(140+mouseX/80,250-mouseY/9); point(180+mouseX/80,290-mouseY/9); point(50+mouseX/80,280-mouseY/9); point(20+mouseX/80,240-mouseY/9); point(250+mouseX/80,240-mouseY/9); point(295+mouseX/80,260-mouseY/9); point(370+mouseX/80,50-mouseY/9); point(380+mouseX/80,150-mouseY/9); point(330+mouseX/80,20-mouseY/9); point(340+mouseX/80,85-mouseY/9); point(275+mouseX/80,200-mouseY/9); point(120+mouseX/80,290-mouseY/9); point(250+mouseX/80,285-mouseY/9); point(290+mouseX/80,40-mouseY/9); point(380+mouseX/80,300-mouseY/9); point(345+mouseX/80,280-mouseY/9); point(150+mouseX/80,330-mouseY/9); point(365+mouseX/80,380-mouseY/9); point(270+mouseX/80,330-mouseY/9); point(20+mouseX/80,325-mouseY/9); point(345+mouseX/80,320-mouseY/9); //Planet Background fill(0,108,141); noStroke(); ellipseMode (CENTER); ellipse(100+mouseX/110,80-mouseY/12,350,350); fill(0,180,80); noStroke(); ellipseMode(CENTER); ellipse(40+mouseX/110,140-mouseY/12, 145,100); ellipseMode(CENTER); ellipse(180+mouseX/110,40-mouseY/12, 180,90); ellipseMode(CENTER); ellipse(100+mouseX/110,237-mouseY/12, 130,30); // X-Wing Target Body fill(210); stroke(210); strokeWeight(3); rectMode(CENTER); rect(0+mouseX,400-mouseY,38,38); triangle(-20+mouseX,380-mouseY,-30+mouseX,400-mouseY,-20+mouseX,420-mouseY); triangle(20+mouseX,380-mouseY,30+mouseX,400-mouseY,20+mouseX,420-mouseY); //X-Wing target Wings strokeWeight(7); line(-26+mouseX,390-mouseY,-90+mouseX,360-mouseY); strokeWeight(7); line(26+mouseX,390-mouseY,90+mouseX,360-mouseY); strokeWeight(7); line(26+mouseX,410-mouseY,88+mouseX,455-mouseY); strokeWeight(7); line(-26+mouseX,410-mouseY,-88+mouseX,455-mouseY); //X-Wing taret Thrusters stroke(255,0,0); strokeWeight(2); fill(255,160,0); ellipseMode(CENTER); ellipse(-17+mouseX,381-mouseY,14,14); stroke(255,0,0); strokeWeight(2); fill(255,160,0); ellipseMode(CENTER); ellipse(-17+mouseX,420-mouseY,14,14); stroke(255,0,0); strokeWeight(2); fill(255,160,0); ellipseMode(CENTER); ellipse(17+mouseX,381-mouseY,14,14); stroke(255,0,0); strokeWeight(2); fill(255,160,0); ellipseMode(CENTER); ellipse(17+mouseX,420-mouseY,14,14); //Tie Fighter Code //Frame Bodywork noFill (); stroke(0); strokeWeight (10); ellipseMode (CENTER); ellipse(200,255,500,500); // Line Right noFill (); stroke(0); strokeWeight(12); line(325,40,260,140); //Line Left noFill (); stroke(0); strokeWeight(12); line(75,40,140,140); //Center smaller circle noFill (); stroke(0); strokeWeight (10); ellipseMode (CENTER); ellipse(200,253,250,250); //Line bottom right noFill (); stroke (0); strokeWeight (14); line (318,308,400,308); //Line bottom left noFill (); stroke (0); strokeWeight (14); line (0,308,80,308); //Red lock-on indicator fill(400-mouseY,0,0,75); noStroke(); ellipseMode(CENTER);ellipse(201,255,239,242); // Tie-Fighter Control Pannel noStroke(); fill (140); rectMode (CENTER); rect(200,400,400,180); noStroke(); fill(2); triangle(0,400,0,335,130,400); noStroke(); fill(2); triangle(400,400,400,335,270,400); noFill(); stroke(0); strokeWeight(12); line (0,-2,75,40); noFill(); stroke(0); strokeWeight(12); line (400,-2,325,40); //Tie Fighter movement stick fill(30); strokeWeight (2); noStroke(); //Good rect(197, 360+mouseY/6, 25, 100); rect(201, 390+mouseY/6, 33, 20); triangle(207, 360+mouseY/6, 207, 380+mouseY/6, 217, 380+mouseY/6); triangle(208, 322+mouseY/6, 208, 343+mouseY/6, 220, 322+mouseY/6); triangle(174, 316+mouseY/6, 195, 316+mouseY/6, 200, 340+mouseY/6); ellipse(200, 313+mouseY/6, 30, 30); //red fill(230, 40, 40); stroke(0, 0, 0); ellipse(215, 317+mouseY/6, 10, 10); //red fill(230, 40, 40); rect(180, 310+mouseY/6, 10, 10); //Red fill(230, 40, 40); stroke (0); strokeWeight(1); rect(199, 312+mouseY/6, 10, 20); //Buttons strokeWeight(1); fill(255,0,0); stroke(255); ellipseMode (CENTER); ellipse(65,328,12,12); strokeWeight(1); fill(0,255,0); stroke(255); ellipseMode (CENTER); ellipse(85,328,12,12); strokeWeight(1); fill(255,0,0); stroke(255); ellipseMode (CENTER); ellipse(105,328,12,12); strokeWeight(1); fill(0,255,0); stroke(255); ellipseMode (CENTER); ellipse(125,328,12,12); strokeWeight(1); fill(255,0,0); stroke(255); ellipseMode (CENTER); ellipse(77,350,12,12); strokeWeight(1); fill(0,255,0); stroke(255); ellipseMode (CENTER); ellipse(97,350,12,12); strokeWeight(1); fill(255,0,0); stroke(255); ellipseMode (CENTER); ellipse(117,350,12,12); //Switch fill (0,80,255); stroke(0); rectMode (CENTER); rect(265,345,10,20); fill (255,80,0); stroke(0); rectMode (CENTER); rect(280,345,10,20); } //Lasers void mousePressed(){ frameRate(5); fill(0,255,0); stroke(0,255,0); strokeWeight(7); line(15+mouseX,mouseY,305,308); line(-15+mouseX,mouseY,97,308); }