2014年4月28日 星期一

第十一週上課內容




int  stage=0,hourseID=0,oldTime=0;
void setup(){
  size(600,400); textSize(40);
}
void draw(){
  if(stage==0){ 
    background(0);
    text("wait for you 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,255,0); text("run run my hourse",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,0,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;
}

沒有留言:

張貼留言