วันเสาร์ที่ 12 กันยายน พ.ศ. 2558

Lab 4 : flocks of birds


int birdSize=50;
int colour=250;
int wingMove;
void setup(){
size(300,300);
}
void draw() {
  background(#BBEEFA);
  //flying_bird();
  draw_flocks(mouseX, mouseY);
  flying_bird();
}
void draw_bird(int x, int y) {
  strokeWeight(0);
  //body
  fill(colour);
  ellipse(x,y,birdSize,birdSize);
  //eyes
  fill(#675143);
  ellipse(x-(birdSize/5), y-(birdSize/6), birdSize/6, birdSize/6);
  ellipse(x+(birdSize/5), y-(birdSize/6), birdSize/6, birdSize/6);
  //mouth
  fill(#FFFF00);
  triangle(x-(birdSize/4), y+(birdSize/6), x+(birdSize/4), y+(birdSize/6), x, y+birdSize/3);
    //wings
  strokeWeight(10);
  stroke(colour);
  line(x-(birdSize/2), y, x-birdSize, wingMove);
  line(x+(birdSize/2), y, x+birdSize, wingMove);
}
void flying_bird() {
  wingMove = mouseY;
  if (frameCount%30 > 15) {
    wingMove += birdSize/3;
  } else {
    wingMove -= birdSize/3;
  }
}
void draw_flocks(int x,int y) {
  int n=0;
  int posX=0;
  while (n<3) {
    fill(colour);
    draw_bird(mouseX+posX,mouseY);
    n++;
    posX += 100;
 
  }
}
void keyPressed() {
  colour = color(random(0, 225), random(0, 225), random(0, 225));
}

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

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