วันอังคารที่ 15 กันยายน พ.ศ. 2558

Lab4-plant as zombie

int shoot;
int colour;
void setup(){
  size(500,500);
  }
void draw(){
  int n = 0;
  int count = 3;
  int another = 0;
  int x = 100;
  int y = 100;
  size(500,500);
  background(#FFFFFF);
  while(n<=count){
  zombie(x+another,y);
  another+=100;
  n+=1;
  }
  plant(mouseX,mouseY);
  pea(shoot,colour);
  advice(10,400);
  if( mousePressed == true){
    colour=#99ff00;
    shoot+=10;
  }
  while(shoot>350){
    shoot=0;
  }

}
void plant(int x, int y){
  stroke(#339900);
  strokeWeight(5);
  fill(#99FF00);
  arc(x-100,y,100,150,PI,TWO_PI);
  arc(x-100,y,100,100,PI,TWO_PI);
  fill(#FFFFFF);
  arc(x-100,y,100,70,PI,TWO_PI);
  fill(#99FF00);
  arc(x+20,y+100,100,200,HALF_PI,PI+HALF_PI);
  fill(#FFFFFF);
  arc(x+20,y+100,70,200,HALF_PI,PI+HALF_PI);
  //head
  stroke(#339900);
  strokeWeight(5);
  fill(#99FF00);
  ellipse(x-20,y+100,50,25);
  ellipse(x,y,200,200);//face
  ellipse(x+120,y+20,100,140);//mouth

  fill(#000000);
  ellipse(x+130,y+20,50,100);//hole

  //eye
  stroke(#000000);
  strokeWeight(1);
  ellipse(x+10,y-30,40,70);//Reye
  ellipse(x+50,y-40,30,60);//Leye
  fill(#FFFFFF);
  ellipse(x+5,y-40,15,30);
  ellipse(x+45,y-50,10,20);

  stroke(#339900);
  strokeWeight(5);
  fill(#00CC00);
  ellipse(x+70,y+200,100,50);
  ellipse(x-30,y+200,100,50);
  }
void pea(int shoot, int Gcolor){
  int r = 50;
  fill(colour);
  noStroke();
  ellipse(mouseX+130+shoot,mouseY+20,r,r);
}
void advice(int x, int y){
  textSize(30);
  fill(0);
  text("Press left mouse to shoot",x,y);
}
void zombie(int x, int y){
  fill(#999999);
  rect(x-30,y+30,60,30,20);
  ellipse(x,y,100,100);
  fill(#FFFFFF);
  ellipse(x-20,y-10,30,30);
  ellipse(x+20,y-10,30,30);
  rect(x-20,y+30,40,20,20);
  fill(0);
  ellipse(x-25,y-15,5,5);
  ellipse(x+20,y-5,5,5);

}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น