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

Lab.5 Class balloon

int R ;
int G ;
int B ;
class Balloon {
  float x;
  float y;
  int r_x;
  int r_y;
  float moveX;
  float moveY;

  Balloon(float x, float y, int r_x, int r_y, float moveX, float moveY) {
    this.x = x;
    this.y = y;
    this.r_x = r_x;
    this.r_y = r_y;
    this.moveX = moveX;
    this.moveY = moveY;
  }
  void display () {
    ellipse(this.x, this.y, this.r_x, this.r_y);
    triangle(this.x - (this.r_x/5), this.y + (2*(this.r_y/3)), this.x, this.y + (this.r_y/2), this.x + (this.r_x/5), this.y + (2*(this.r_y/3)));
    line(this.x, this.y + (this.r_y/2), this.x, this.y + 1.5*this.r_y);
 
}
  void move () {
    this.y = this.y - this.moveY;
    //this.x = this.x + this.moveX;
  }
}
Balloon []a = new Balloon[3];
void setup () {
  size(400, 300);
  a[0] = new Balloon(100, 250, 50, 70, 0.5, 1);
  a[1] = new Balloon(150, 300, 40, 60, -0.5, 1);
  a[2] = new Balloon(200, 200, 60, 80, 1, 2);
}
void draw () {
  background(255);
  for (Balloon i : a) {
    i.display();
    i.move();
  }
}

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

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