2020年4月23日 星期四

樹梅派吃樹梅

void setup(){
  size(600,300);
}
int x=50,y=50,a=45,da=1;//da->the change of angle a,set as 1
int i,j;
int[][]bean={
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,0,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
};
void draw(){//60 times per second
  background(#AEE5AE);
  fill(#C17373);
  for(i=0;i<6;i++){
    for(j=0;j<8;j++){
      if(bean[i][j]==1)
      {
        ellipse(j*100+50, i*100+50,6,6);
      }
      if(dist(x,y, j*100+50,i*100+50)<50)
      {
        bean[i][j]=0;
      }
    }
  }
  arc(x,y,100,100, radians(a),radians(360-a),PIE);
  x++;
  a+=da;//decrease or enlarge
  if(a>60)
  {
    da=-1;//too big-> decrease
  }
  if(a<=0)
  {
    da=+1;//too small-> enlarge
  }
}

沒有留言:

張貼留言