วันจันทร์ที่ 25 สิงหาคม พ.ศ. 2557

Lab 2 - Task#3 : Bicycle


int s=400;

void setup() {
  size(400, 400);
}
void draw() {
  stroke(150);
  strokeWeight(1);
  background(206,229,241);

  for (int i=0; i<width; i=i+10) {
    line(0, i, width, i);
  }
  for (int i=0; i<height; i=i+10) {
    line(i, 0, i, height);
  }
  //floor
  fill(0);
  if(frameCount>=20)
  {if(frameCount<=40){for(int i=0-10;i<=s;i=i+30){rect(i,300,10,100);}}}
  if(frameCount>=40)
  {for(int i=0-20;i<=s;i=i+30){rect(i,300,10,100);}}
  if(frameCount<=20)
  {for(int i=0-30;i<=s;i=i+30){rect(i,300,10,100);}}
  fill(220,0,0);
  if(frameCount>=20)
  {if(frameCount<=40){for(int i=0-20;i<=s;i=i+30){rect(i,300,10,100);}}}
  if(frameCount>=40)
  {for(int i=0-30;i<=s;i=i+30){rect(i,300,10,100);}}
  if(frameCount<=20)
  {for(int i=0-10;i<=s;i=i+30){rect(i,300,10,100);}}
  fill(130,0,0);
  if(frameCount>=20)
  {if(frameCount<=40){for(int i=0-30;i<=s;i=i+30){rect(i,300,10,100);}}}
  if(frameCount>=40)
  {for(int i=0-10;i<=s;i=i+30){rect(i,300,10,100);}}
  if(frameCount<=20)
  {for(int i=0-20;i<=s;i=i+30){rect(i,300,10,100);}}
  if(frameCount==60){frameCount=0;}
  draw_bike(200, 200);
}
void draw_bike(int x, int y) {

  translate(x-100, y+50);
  for (int i=0; i<=8; i=i+1) {
    noFill();

    stroke(255);
    strokeWeight(2);
    rotate (45);
    line(-50, 0, 50, 0);
    stroke(0);
    strokeWeight(10);
    ellipse(0, 0, 100, 100);
  }
  rotate (-405);
  translate(x, 0);
  for (int i=0; i<=8; i=i+1) {
    noFill();

    strokeWeight(2);
    stroke(255);
    line(-50, 0, 50, 0);
    rotate (45);
    strokeWeight(10);
    stroke(0);

    ellipse(0, 0, 100, 100);
  }
  rotate (-405);          //Body
  translate(-x/2, -y/4);
  stroke(255,0,0);
  strokeWeight(10);
  line(-100, 50, -50, -50);
  line(-25, -50, -50, -50);
  line(-60, -25, 50, -25);
  line(-60, -25, 0, 50);
  line(100, 50, 50, -25);
  line(100, 50, 0, 50);
  line(55, -35, 0, 50);
  line(70, -40, 40, -40);
 
}

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

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