2016年12月19日 星期一

week 16

int input[] = {8,6,4,0,1,3,2,5,7}, N=0, minus=0;
void setup(){
  size(600,600);
}
int score=0;
void draw(){
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      fill(255); rect(i*200,j*200,200,200);
      fill(255,0,0); rect(i*200+50,j*200+50,100,100);
    }
  }
  fill(34,177,76); textSize(40); text("Score:"+score, 225,40);

  int x=(input[N]%3), y=int(input[N]/3);
  fill(153,217,234,150); rect(x*200+minus/2,y*200+minus/2,200-minus,200-minus);
  minus++;
  if(minus>200){
    minus=0; N++;
    if(N>=input.length) N=0;
  }
}
void keyPressed(){
  int x=-1,y=-1;
  if(key>='1' && key<='9'){
    int now=key-'1';
    if(now<3) now+=6;
    else if(now>5) now-=6;
    if(now == input[N]){
      println("good");
      score+=10;
    }
    else {
    println("bad");
    score-=10;
    }
  }
  minus=0; N++;
  if(N>=input.length) N=0;
}

沒有留言:

張貼留言