วันอังคารที่ 11 พฤศจิกายน พ.ศ. 2557

Class Balloon 1 balloon(variable)

//balloon
Balloon b;

void setup () {
  size (500, 500);
  b = new Balloon (250, 250, 100);
}

void draw () {
  background (255);
  b.display();
  b.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;
    }
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น