2013年10月20日 星期日

第7週上課內容

1. 請列出你今天三個小時,要完成的事
用prcessing掉垃圾~

2. 你在期中作品要做到什麼程度

可以執行~
3. Why? 你為什麼要做它

如何運用processing做小遊戲


1.
int N=4;
float []thingX= new float[4], thingY= new float[4],thingType= new float[4];
void setup(){
size(400,600);
for(int i=0 ;i<N ;i++){
newThing(i);
}
}

void draw(){
background(255);
for(int i=0;i<N;i++){
  if(thingType[i]==1) drawGood(i);
  else if(thingType[i]==2) drawBad(i);
  else if(thingType[i]==3) drawTrash(i);
  thingY[i]+=4;
  if(thingY[i]>600) newThing(i);
  }
}

void newThing(int i){
 thingY[i]=-random(200);
thingX[i]=random(400);
thingType[i]=int (random(3)+1);
  }
  
  void drawGood(int i){  fill(255,0,0);   ellipse(thingX[i],thingY[i],40,60);  }
  
  void drawBad(int i){  fill(0);   ellipse(thingX[i],thingY[i],40,60); }


  void drawTrash(int i){  fill(#FF6803);  rect(thingX[i],thingY[i],60,60); }


 加入倒數器

  int countDown=10*30;
  void draw() {
  if(countDown>0){
  background(255,0,0);
  countDown--;
  text("Count Down"+countDown/30,100,100);
  return;

  }



加入鍵盤互動

void keyPressed(){
 if(keyCode==UP) ManY-=10; 
  if(keyCode==DOWN) ManY+=10; 
   if(keyCode==RIGHT) ManX+=10; 
    if(keyCode==LEFT) ManX-=10; 
  

}




沒有留言:

張貼留言