2014年4月28日 星期一

WEEK11 課堂內容

int stage=0, hourseID=0, oldTime=0;
void setup(){
  size(600,400);
  textSize(40);
}
void draw(){
  if(stage==0){
    background(0);
    text("Wait for your Input/UP",100,100);
  }
  else if(stage==1){
    background(255, 0, 0);
    text("Select your hourse",100,100);
    text("Now Select"+hourseID, 200,200);
    oldTime=millis();
  }
  else if(stage==2){
    background(0,0,255);
    text("Run Run my Hourse "+hourseID,100,100);
    int nowTime=millis();
    int t=int((nowTime-oldTime)/1000);
    text("Running "+t,200,200);
    if(t>20) stage=3;
  }
  else if(stage==3){
    background(0,0,255);
  }
  else background(255,255,0);
}
void keyPressed(){
  if(keyCode==UP){
    if(stage==0) stage=1;
    else if(stage==1) stage=2;
    else if(stage==2) stage=3;
  }
  if(keyCode==RIGHT) hourseID=(hourseID+1)%4;
  if(keyCode==LEFT) hourseID=(hourseID-1+4)%4;
}

沒有留言:

張貼留言