int t[ ][ ] = {
{
0, 1, 2, 3, 4, 5, 6, 7
}
,
{
0, 1, 2, 3, 4, 5, 6, 7
}
};
int c[ ][ ]= {
{
2, 3, 4, 5, 6, 4, 3, 2
}
,
{
1, 1, 1, 1, 1, 1, 1, 1
}
,
{
0, 0, 0, 0, 0, 0, 0, 0
}
,
{
0, 0, 0, 0, 0, 0, 0, 0
}
,
{
0, 0, 0, 0, 0, 0, 0, 0
}
,
{
0, 0, 0, 0, 0, 0, 0, 0
}
,
{
1, 1, 1, 1, 1, 1, 1, 1
}
,
{
2, 3, 4, 5, 6, 4, 3, 2
}
};
void setup() {
size(500, 500);
for (int a=0 ; a<t[0].length ; a=a+1) {
for (int b=0 ; b<t[1].length ; b++) {
chanal(t[0][a]*(width/t[0].length), t[1][b]*(height/t[1].length));
if ( a%2==0 && b%2==0 ) {
chanal2(t[0][a]*(width/t[0].length), t[1][b]*(height/t[1].length));
}
if ( a%2==1 && b%2==1 ) {
chanal2(t[0][a]*(width/t[0].length), t[1][b]*(height/t[1].length));
}
}
}
side();
}
void chanal(int x, int y) {
strokeWeight(3);
fill(255, 0, 0);
noStroke();
rect(x, y, width/t[0].length, height/t[1].length);
noFill();
}
void chanal2(int x, int y) {
strokeWeight(3);
fill(0);
rect(x, y, width/t[0].length, height/t[1].length);
noFill();
strokeWeight (3);
stroke(153, 51, 0);
}
void side() {
for (int i=0 ; i<c.length ; i++) {
for (int j=0 ; j<c.length ; j++) {
if (c[j][i]==1) {
Prawn (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
if (c[j][i]==2) {
Rook (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
if (c[j][i]==3) {
Knight (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
if (c[j][i]==4) {
Bishop (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
if (c[j][i]==5) {
King (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
if (c[j][i]==6) {
Queen (((width/c[j].length)/2)+(i*(width/c[j].length)), ((height/c.length)/2)+(j*(height/c.length)));
}
}
}
}
void Rook(int x, int y) {
fill(0, 0, 255);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(255);
text("Rook", x-(width/c.length)/4, y);
}
void Knight(int x, int y) {
fill(0, 0, 255);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(255);
text("Knight", x-(width/c.length)/3, y+4);
}
void Bishop(int x, int y) {
fill(0, 0, 255);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(255);
text("Bishop", x-(width/c.length)/3, y+4);
}
void Queen(int x, int y) {
fill(0, 0, 255);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(255);
text("Queen", x-(width/c.length)/3, y+4);
}
void King(int x, int y) {
fill(0, 0, 255);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(255);
text("King", x-(width/c.length)/4, y+4);
}
void Prawn(int x, int y) {
fill(255, 255, 0);
ellipse(x, y, (width/c.length)/1.2, (height/c.length)/1.2);
fill(0);
text("Prawn", x-(width/c.length)/3, y+4);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น