//Moth class class Moth{ float x, y, c1, c2, c3, c4, aSpeed; //Moth Variables: head location(x,y-first triangle coordinate) Moth(float tempX, float tempY, float tempc1, float tempc2, float tempc3, float tempc4, float tempAspeed){ //Moth constructor x = tempX; y = tempY; c1 = tempc1; c2 = tempc2; c3 = tempc3; c4 = tempc4; aSpeed = tempAspeed; } //Display Moth void display() { fill (c1, c2, c3,c4);//moth colour noStroke (); triangle (x-65, y-10, x-15, y+10, x-25, y-10);//upper left wing stroke(120, 60, 140, 255); ellipse (x-35, y-5, 10, 10); //wing pattern a concentric white circles ellipse (x-35, y-5, 4, 4); fill (c1,c2,c3,c4); noStroke (); triangle (x+25, y-10, x+15, y+10, x+65, y-10);//upper right wing stroke(120, 60, 140); ellipse (x+35, y-5, 10, 10);//wing pattern a ellipse (x+35, y-5, 4, 4); stroke (120, 60, 140,255); line (x-5, y+10, x-35, y-30);//left antenna ellipse (x-35, y-30, 2, 2);//left antenna end line (x+5, y+10, x+35, y-30);//right antenna ellipse (x+35, y-30, 2, 2);//right antenna end fill (c1,c2,c3,c4); noStroke (); triangle (x,y, x+15, y+10, x-15 , y+10); //head triangle (x-15, y+10, x+15, y+10, x, y+60);//body fill (120, 60, 140, 255); //purple ellipse (x+5, y+15, 6, 22);// body marking ellipse (x-5, y+15, 6, 22); //body marking fill (c1,c2,c3,c4); noStroke (); triangle(x-15, y+10, x-70, y+60, x-50, y+5);// lower left wing fill (120, 60, 140,255);//purple noStroke (); ellipse (x-20, y+15, 11, 11); // wing pattern b purple dot fill (c1,c2,c3,c4); triangle(x+50, y+5, x+70, y+60, x+15, y+10);//lower right wing fill (120, 60, 140,255); noStroke (); ellipse (x+20, y+15, 11, 11);// wing pattern b } void move(){ //defines speed/movement x=x+aSpeed;//position x moves at speed of a if ((x>width)||(x<0))//if x exceeds width oject reverses aSpeed= aSpeed*-1;//changes polarity to reverse movement } }