2014年9月22日 星期一

Week02 葉正聖老師示範

https://www.coursera.org/course/digitalmedia
Creative Programming for Digital Media & Mobile Apps
https://class.coursera.org/cdt208-002
Introduction to Computational Arts



試著做出可以互 動的程式哦!
第一行, 改成有 void setup() 及 void draw() 的版本, 讓方塊的座標是滑鼠的位置







https://www.youtube.com/watch?v=JOCEjIwMRr8

void setup(){
  size(600,800);
}
int flying=0;
float eggX=300, eggY=600, eggVX,eggVY;
void draw(){
  background(0);
  ellipse(eggX,eggY, 100,100);
  if(flying>0){
    eggX+= eggVX;  eggY+= eggVY;
    flying--;
  }
}
void mouseDragged(){
  eggX=mouseX; eggY=mouseY;
}
void mouseReleased(){
  flying=30;
  eggVX= (400-eggX)/30;
  eggVY= (200-eggY)/30;
}




沒有留言:

張貼留言