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

Othello



int [][] Mak= {
  {
    0, 1, 0, 1, 0, 1, 0, 1
  }
  , {
    0, 0, 0, 0, 0, 0, 0, 0
  }
  , {
    1, 1, 1, 1, 1, 1, 1, 1
  }
  , {
    1, 0, 0, 0, 0, 0, 0, 1
  }
  , {
    0, 1, 1, 0, 1, 1, 0, 1
  }
  , {
    1, 0, 0, 1, 0, 0, 1, 0
  }
  , {
    0, 1, 1, 1, 0, 0, 0, 1
  }
  , {
    1, 0, 0, 0, 1, 1, 1, 0
  }
};
void setup() {
  size(500, 500);
  background(153, 255, 0);
  drawtable();
  drawCircle();
}
void drawtable() {
  int a = 2;
  float h1 = 0;
  float x = width/8;
  float h2 = 0;
  float y = height/8;
  stroke (102, 51, 0);
  strokeWeight(3);
  while (a < 9) {
    line(h1+x, 0, h1+x, height);
    line(0, h2+y, width, h2+y);
    h1 = h1+x;
    h2 = h2+y;
    a = a+1;
  }
}
void drawCircle() {
  int i = 0, j = 0, count = 0;
  float b = width/16, q = width/8;
  float c = height/16, e = height/8;

  while (i < Mak.length) {
    while (j < Mak[i].length) {
      if (Mak[i][j] == 1) {
        noStroke();
        fill(255);
        ellipse(b, c, width/10, width/10);
      }
      if (Mak[i][j] == 0) {
        noStroke();
        fill(0);
        ellipse(b, c, width/10, width/10);
      }
      b = b+q;
      j = j+1;
    }

    b = width/16;
    c = c+e;
    j = 0;
    i = i+1;
  }
}

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

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