Balloon b;
Balloon a;
void setup () {
size (500, 500);
a = new Balloon (250, 450, 80);
b = new Balloon (250, 250, 100);
}
void draw () {
background (255);
b.display();
a.display ();
b.move_up();
a.move_up();
}
class Balloon {
int x;
int y;
int r;
Balloon (int x, int y, int r) {
this.x = x;
this.y = y;
this.r = r;
}
void display () {
fill (255, 255, 0);
line (this.x, this.y, this.x, this.y+r);
ellipse (this.x, this.y, this.r, this.r);
}
void move_up () {
this.y = this.y -1;
if (this.y <= 10) {
this.y = height;
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น