2016年12月26日 星期一

week 17

int input[] = {-1,-1,6,4,0,1,3,2,5,7}, N=0, minus=0;
int input2[] = {7,6,-1,3,-1,-1,5,4,6,3};
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);

  if(N>=0){
    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);
    int a=(input2[N]%3), b=int(input2[N]/3);
    fill(153,217,234,150); rect(a*200+minus/2,b*200+minus/2,200-minus,200-minus);
  }
  minus++;
  if(minus>200){
    if(input[N]!=-1) score-=10;
    if(input2[N]!=-1) score-=10;
    minus=0; N++;
    if(N>=input.length) N=0;
  }
}
void keyPressed(){
  int x=-1,y=-1,a=-1,b=-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]){
      input[N]=-1;
      println("good");
      score+=10;
      if( abs(minus-100)<10) score+=100;
    }
    if(now == input2[N]){
      input2[N]=-1;
      println("good");
      score+=10;
      if( abs(minus-100)<10) score+=100;
    }
  }
  if(input[N]==-1 && input2[N]==-1){
    minus=0; N++;
    if(N>=input.length) N=0;
  }
}

沒有留言:

張貼留言