2016年3月24日 星期四

02163042_王冠閔_week05

示範老師在網站上看到的範例

網站上示範






做出一個視窗讓眼睛轉動


程式碼:

void setup(){
  size(120,100);
}
void draw(){
  float t = frameCount/180.0*PI;
  background(0);
  fill(255);
  ellipse(40,50, 33,33);
  ellipse(120-40,50, 33,33);
  fill(0);
  ellipse(40+15*cos(t),50+15*sin(t), 5,5);
  ellipse(120-40+15*cos(t),50+15*sin(t), 5,5);
}

讓眼睛跟者滑鼠動

程式碼:

void setup(){
  size(320,300);
}
void draw(){
  //float t = frameCount/180.0*PI;
  background(0);
  fill(255);
  ellipse(40,50, 33,33);
  ellipse(120-40,50, 33,33);
  fill(0);
  float t=atan2(mouseY-50,mouseX-45);
  ellipse(40+15*cos(t),50+15*sin(t), 5,5);
  t=atan2(mouseY-50,mouseX-(120-40));
  ellipse(120-40+15*cos(t),50+15*sin(t), 5,5);
}

沒有留言:

張貼留言