วันพุธที่ 1 ตุลาคม พ.ศ. 2557

The Bicycle in Array & Function & Loop

int colour [] = {
  0, 102
};
int fill [] = {
  102, 153
};
int driveBicycle [] = {
  150, 400
};
int a = 700;

void setup () {
  size (600, 300);
  frameRate(50);
}

void draw () {
  int driveBicycleA = a;

  background (255);
  a = a-1;
  if (a <= 0) {
    a =width;
  }
  if (mouseX>= width/2 && mouseY >= height/2) {
    fill(0);
    textSize(20);
    text ("The Bicycle", (width/2)-50, 30);
  }
  draw_bicycle (driveBicycleA, 204, 255);

  for (int i = 0; i<driveBicycle.length; i++) {
    draw_bicycle (driveBicycle[i], fill[i], colour[i]);
  }
}

void draw_bicycle (int driveBicycle, int fill, int colour) {
  int i = 0;
  strokeWeight (10);
  stroke (102, 51, 0);
  line (driveBicycle, (height/2)-30, driveBicycle+30, (height/2)-30);

  stroke (colour, 51, 0);
  line (driveBicycle-50, (height/2), driveBicycle+50, (height/2));
  line (driveBicycle-50, (height/2)-100, driveBicycle-50, (height/2)+20);
  line (driveBicycle-50, (height/2)-50, driveBicycle+50, (height/2));

  stroke (0);
  fill (fill);
  ellipse (driveBicycle-50, (height/2)+50, 70, 70);
  ellipse (driveBicycle+70, (height/2)+30, 100, 100);
  ellipse (driveBicycle-50, (height/2)+50, 20, 20);
  ellipse (driveBicycle+70, (height/2)+30, 50, 50);

  strokeWeight (15);
  stroke (255, 51, 0);
  line (driveBicycle-70, (height/2)-100, driveBicycle-10, (height/2)-100);
}



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

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