class Balloon{
float x;
float y;
float r;
Balloon(int x, int y, int r){
this.x = x;
this.y = y;
this.r = r;
}
void display(){
line(this.x , this.y, this.x, this.y+this.r);
ellipse(this.x, this.y, this.r, this.r);
}
void move_up(){
this.y = this.y-3;
if(this.y < 0){this.y = height;}
}
void move_right(){
this.x = this.x+1.5;
if(this.x > width){this.x = 0;}
}
void fill_c(){
fill(this.x+this.y-445);
}
}
int B_num = 6;
Balloon b[] = new Balloon[B_num];
void setup(){
size(500, 500);
for( int i = 0; i < B_num; i++){
b[i] = new Balloon(63+(i*63), height, 50);
}
}
void draw(){
background(255);
for( int i = 0; i < B_num; i++){
b[i].fill_c();
b[i].display();
b[i].move_up();
b[i].move_right();
}
}
No comments:
Post a Comment