//balloon
Balloon b;
Balloon [] a = new Balloon [3];
void setup () {
size (500, 500);
b = new Balloon (250, 250, 100);
a [0] = new Balloon (100, 300, 50);
a [1] = new Balloon (400, 300, 50);
a [2] = new Balloon (250, 400, 20);
}
void draw () {
background (255);
b.display();
a[0].display();
a[1].display();
a[2].display();
b.move_up();
a[0].move_up();
a[1].move_up();
a[2].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 (x, y, x, y+r);
ellipse (x, y, r, r);
}
void move_up () {
this.y = this.y -1;
if (this.y <= 10) {
this.y = height;
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น