int shoot;
int colour;
void setup(){
size(500,500);
}
void draw(){
size(500,500);
background(#FFFFFF);
plant(mouseX,mouseY);
pea(shoot,colour);
advice(10,400);
if( mousePressed == true){
colour=#99ff00;
shoot+=5;
}else if(mouseButton == RIGHT){
colour=0;
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);
text("Press right mouse to reset pea",x,y+50);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น