วันเสาร์ที่ 21 กันยายน พ.ศ. 2556

Chessboard

void setup() {
  background(0);
  size(400, 400);//
}
  int [][]a= { {  0, 100,200, 300 }, {  50, 50,50,50},{150,150,150, 150},{250,250,250,250},{350,350,350,350 } };//มีการประกาศและกำหนดเป็น array
  int i=0;//
  void draw(){
    drawOthello();//
  }

void drawOthello() {//

  while (i<a[0].length) {
    rect(a[0][i],a[2][i] , 50, 50);
    rect(a[0][i],a[1][i] , 50, 50);
    rect(a[0][i],a[3][i] , 50, 50);
    rect(a[0][i],a[4][i] , 50, 50);
    rect(a[0][i]+50,a[2][i]-50 , 50, 50);
    rect(a[0][i]+50,a[1][i]-50 , 50, 50);
    rect(a[0][i]+50,a[3][i]-50 , 50, 50);
    rect(a[0][i]+50,a[4][i]-50 , 50, 50);
    i=i+1;
  }

}




ไม่มีความคิดเห็น:

แสดงความคิดเห็น