我爸的英文名字:Kelevin
彩色球球
程式碼:
int []x=new int[1000];
int []y=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
size(400,400);
}
void draw(){
background(255);
for(int i=0;i<n;i++){
fill(c[i]);
circle(x[i],y[i],40);
y[i]+=2;
}
}
void mousePressed(){
x[n]=mouseX;
y[n]=mouseY;
c[n]=color(random(255),random(255),random(255));
n++;
}
氣球
程式碼:
int []x=new int[1000];
int []y=new int[1000];
int []r=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
size(400,400);
}
void draw(){
background(255);
for(int i=0;i<n;i++){
fill(c[i]);
circle(x[i],y[i],r[i]);
y[i]--;
}
if(mousePressed) r[n-1]++;
}
void mousePressed(){
x[n]=mouseX;
y[n]=mouseY;
r[n]=10;
c[n]=color(random(255),random(255),random(255));
n++;
}
氣球VER2:
class Bubble{
int x;
int y;
int r;
color c;
}
Bubble[] b=new Bubble[1000];
int n=0;
void setup(){
size(400,400);
}
void draw(){
background(255);
for(int i=0;i<n;i++){
fill(b[i].c);
circle(b[i].x,b[i].y,b[i].r);
b[i].y--;
}
if(mousePressed) b[n-1].r++;
}
void mousePressed(){
b[n]= new Bubble();
b[n].x=mouseX;
b[n].y=mouseY;
b[n].r=10;
b[n].c=color(random(255),random(255),random(255));
n++;
}
沒有留言:
張貼留言