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);
}
}
this.x =
Balloon b1;
Balloon b2;
void setup(){
size(500, 500);
b1 = new Balloon(150, 150, 50);
b2 = new Balloon(250, 250, 50);
}
void draw(){
background(255);
b1.fill_c();
b1.display();
b1.move_up();
b1.move_right();
b2.fill_c();
b2.display();
b2.move_up();
b2.move_right();
}
No comments:
Post a Comment