1.跟著滑鼠移動
void setup(){
size(600,600);
}
void draw(){
fill(255,random(255),200);
rect(100,100,100,100);
fill(255,random(200),200);
rect(400,100,100,100);
fill(253,157,176);
ellipse(mouseX,mouseY,10,10);
}
2.追著滑鼠移動
void setup(){
size(800,600); //視窗大小
}
float [] a = new float[10];
float [] b = new float[10];
float x=100,y=100;
void draw(){
background(0,0,0); //背景全黑
a[9]=mouseX+100;
b[9]=mouseY+100;
for(int i=0;i<9;i++){
PImage img3;
img3= loadImage("4.JPG"); //小雞圖
image (img3,a[i]=a[i+1]+mouseX*0.5,b[i]=b[i+1]+mouseY*0.53);
}
PImage img;
img=loadImage("1.JPG"); //老鷹圖
image(img,mouseX-150,mouseY-100);
PImage img2;
img2=loadImage("3.JPG"); //公雞圖
image(img2 ,x ,y);
x=x*0.9 + mouseX*0.1;
y=y*0.9 + mouseY*0.1;
}
94
回覆刪除