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

Lab 3 : flying bird



int birdSize=100;
int x=30;
int colour=250;
int wingMove;
void setup(){
size(300,300);
}
void draw() {
  background(#BBEEFA);
  wingMove = mouseY;
  if (frameCount%x > x/2) {
    wingMove += birdSize/3;
  } else {
    wingMove -= birdSize/3;
  }
  draw_bird(mouseX, mouseY);
}
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 keyPressed() {
  colour = color(random(0, 225), random(0, 225), random(0, 225));
}

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

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