3-1 跟著滑鼠移動
void setup(){
size(600,600);
background(100,100,100,100);
}
void draw(){
fill(255,255,0);
triangle(mouseX,100,mouseX,150,100,mouseY);
fill(150,20,100);
ellipse(mouseX,mouseY,100,100);
fill(255,255,255);
rect(mouseX,mouseY,100,100);
}
3-2 追著滑鼠移動
void setup(){
size(600,600);
background(100,100,100,100);
}
float x=100,y=100,x1=150,y1=150,x2=200,y2=200;
void draw(){
background(0,150,255,100);
fill(0,255,255);
ellipse(x,y,100,100);
triangle(x,y,mouseX,mouseY,mouseX,mouseY);
fill(255,100,100);
ellipse(mouseX,mouseY,30,30);
fill(255,255,0);
ellipse(x1,y1,100,100);
triangle(x1,y1,mouseX,mouseY,mouseX,mouseY);
fill(0,255,0);
ellipse(x2,y2,100,100);
triangle(x2,y2,mouseX,mouseY,mouseX,mouseY);
x=x*0.9+mouseX*0.1; //x=(x+mouseX)/2;
y=y*0.9+mouseY*0.1; //y=(y+mouseY)/2;
x1=x1*0.5+mouseX*0.3;
y1=y1*0.5+mouseY*0.3;
x2=x2*0.3+mouseX*0.1;
y2=y2*0.3+mouseY*0.1;
}
3-3 心得
今天教的隨滑鼠移動很有趣,謝謝老師。
沒有留言:
張貼留言