// Nicole Glassman Assignment P2 -6 //Use your new class from question 5 to create two instances of your // cute/evil being. Make sure that your class allows you to customize //them slightly so that they don't look identical to one another. [3 pts] // Create class for pig class pig{ int Posx; int Posy; int pigScared; int red1; int green1; int blue1; // create variables pig(int originX, int originY, int originScared, int colourred, int colourgreen, int colourblue) { // constructor Posx = originX; Posy = originY; pigScared = originScared; red1 = colourred; green1 = colourgreen; blue1 = colourblue; } void drawpig(){ // pigs ears fill(red1, green1, blue1); triangle(Posx-40,Posy-70, Posx-60,Posy-100,Posx-20, Posy-70); //left ear triangle(Posx+40,Posy-70, Posx+60,Posy-100,Posx+20, Posy-70); // right ear smooth(); // pigs legs stroke(0); fill(red1, green1, blue1); rectMode(CENTER); rect(Posx-20, Posy+70,40 , 70); rect(Posx+20, Posy+70, 40, 70); // pigs feet fill(0); stroke(225); rect(Posx-25, Posy+ 105, 50, 30); rect(Posx+25, Posy+ 105, 50, 30); // pigs head fill(red1, green1, blue1); noStroke(); ellipse(Posx,Posy-50, 100, 100); // pigs body ellipse(Posx, Posy, 170, 150); // pigs nose stroke(0); fill(0); ellipse(Posx-15, Posy, 25, 25); ellipse(Posx+ 15, Posy, 25, 25); noFill(); ellipse(Posx, Posy, 100, 70); // pigs eyes fill(255); ellipse(Posx-15, Posy-70, 20, 30); ellipse(Posx+ 15, Posy-70, 20, 30); fill(0); ellipse(Posx-15, Posy-65, 7, 7); ellipse(Posx+15, Posy-65, 7, 7); // pigs eyebrows noFill(); stroke (0); arc(Posx+20, Posy-75, 30, 30, TWO_PI-PI/2, TWO_PI); arc(Posx-20,Posy-75, 30, 30, PI, TWO_PI-PI/2); } // move pig routine using mouse up and down movement void movepig(){ if(Posx < mouseX){ Posx = Posx + (1 * pigScared); } if (Posx> mouseX){ Posx= Posx- (1 * pigScared); } if (Posy< mouseY){ Posy = Posy + (1 * pigScared); } if (Posy> mouseY){ Posy = Posy - (1 * pigScared); } if(Posy < 44){ Posy = 44; } if (Posy> 362){ Posy = 362; } if(Posx < 44){ Posx = 44; } if (Posx> 362){ Posx = 44; } } }