2020年5月8日 星期五

week11 glänzen sehen

//int []a=new int[10];//Java's Array
//int []a={3,0,1,8,7,2,5,4,6,9};
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={0,9,1,2,3,5,4,6,7,8};//對於快要排好的東西, 特別快!!!
int []a={9,8,7,6,5,4,3,2,1,0};//最糟的狀況:全倒
void setup(){
  size(500,800);
  //for(int i=0;i<10;i++){//random choose number
  //  a[i]=int(random(10));//亂數決定數字
  //}
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  }
}
void draw(){

}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}

嘴巴開合的小精靈
小精靈嘴巴依舊可以開合,加上鍵盤上下左右可移動小精靈
小精靈上下鍵移動時可以改變小精靈嘴巴方向
加上豆子







沒有留言:

張貼留言