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

Lab 3 : favorite song (change colour)


int moveX=0;
int moveY=0;
int count=2;
int result;
int colour1;
int colour2;
int colour3;
int colour4;


void setup() {
  size(600, 360);
}
void draw() {
  frameRate(2);
  result=count%2;
  count=count+1;
  draw_FerrisWheel();
  draw_bench();
  if (result==0) {
   fill(0);
   text_PASSENGER();
   fill(#7a92be);
   text_LetHerGo();
  }
  if (result==1) {
   fill(#7a92be);
   text_PASSENGER();
   fill(0);
   text_LetHerGo();
  }

}
void draw_FerrisWheel() {
  background(#7a92be);
  //Ferris wheel
  fill(#7a92be);
  stroke(255);
  strokeWeight(3);
  //wheel_1
  ellipse(100+moveX, 100+moveY, 200, 200);
  //wheel_2
  ellipse(100+moveX, 100+moveY, 180, 180);
  //wheel_3
  ellipse(100+moveX, 100+moveY, 100, 100);
  //wheel_4
  fill(255);
  ellipse(100+moveX, 100+moveY, 30, 30);
  //pole
  stroke(255);
  strokeWeight(6);
  //poleL
  line(85+moveX, 100+moveY, 0+moveX, 350+moveY);
  //poleR
  line(115+moveX, 100+moveY, 200+moveX, 350+moveY);
}
void text_PASSENGER() {
  //text"PASSENGER"
  textSize(60);
  text("PASSENGER", 210+moveX, 70+moveY);
}
void text_LetHerGo() {
  textSize(100);
  //text"LET"
  text("LET", 400+moveX, 170+moveY);
  //text"HER"
  text("HER", 300+moveX, 250+moveY);
  //text"GO"
  text("GO", 200+moveX, 330+moveY);
}
void draw_bench(){
  //bench
  noStroke();
  //bench-1
  fill(colour1);
  ellipse(50+moveX, 20+moveY, 10, 10);
  ellipse(50+moveX, 40+moveY, 40, 40);
  //bench-2
  fill(colour2);
  ellipse(180+moveX, 50+moveY, 10, 10);
  ellipse(180+moveX, 70+moveY, 40, 40);
  //bench-3
  fill(colour3);
  ellipse(160+moveX, 175+moveY, 10, 10);
  ellipse(160+moveX, 195+moveY, 40, 40);
  //bench-4
  fill(colour4);
  ellipse(20+moveX, 150+moveY, 10, 10);
  ellipse(20+moveX, 170+moveY, 40, 40);
}
void keyPressed(){
  colour1 = color(random(0, 225), random(0, 225), random(0, 225));
  colour2 = color(random(0, 225), random(0, 225), random(0, 225));
  colour3 = color(random(0, 225), random(0, 225), random(0, 225));
  colour4 = color(random(0, 225), random(0, 225), random(0, 225));
}

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

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