int r = 38;
void setup(){
size(400, 400);
int x, y, i, j;
int[][] Chess= {
{
2, 3, 4, 6, 5, 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, 6, 5, 4, 3, 2
}
};
strokeWeight(4);
for (y=0,i=0 ; i<Chess.length ; i++,y+=50){
for (x=0,j=0 ; j<Chess.length ; j++,x+=50){
if ((j+i)%2 == 0){
fill(66, 217, 146);
}
else fill(192);
rect(x, y, 200, 200);
}
}
for (y=25,i=0 ; i<Chess.length ; i++,y+=50){
for (x=25,j=0 ; j<Chess.length ; j++,x+=50){
if (y<200){
fill(0);
}
else{
fill(255);
}
if (Chess[i][j]==1){
Prawn(x, y);
}
else if (Chess[i][j]==2){
Rook(x, y);
}
else if (Chess[i][j]==3){
Knight(x, y);
}
else if (Chess[i][j]==4){
Bishop(x, y);
}
else if (Chess[i][j]==5){
Queen(x, y);
}
else if (Chess[i][j]==6){
King(x, y);
}
}
}
}
void Rook(int x, int y){
ellipse(x, y, r, r);
fill(255,0,0);
text("Rook", x-14, y+4);
}
}
else if (Chess[i][j]==2){
Rook(x, y);
}
else if (Chess[i][j]==3){
Knight(x, y);
}
else if (Chess[i][j]==4){
Bishop(x, y);
}
else if (Chess[i][j]==5){
Queen(x, y);
}
else if (Chess[i][j]==6){
King(x, y);
}
}
}
}
void Rook(int x, int y){
ellipse(x, y, r, r);
fill(255,0,0);
text("Rook", x-14, y+4);
}
void Knight(int x, int y){
ellipse(x, y, r, r);
fill(255,0,0);
text("Knight", x-17, y+4);
}
void Bishop(int x, int y){
ellipse(x, y, r, r);
fill(255,0,0);
text("Bishop", x-18, y+4);
}
void Queen(int x, int y) {
ellipse(x, y, r, r);
fill(255,0,0);
text("Queen", x-18, y+4);
}
void King(int x, int y) {
ellipse(x, y, r, r);
fill(255,0,0);
text("King", x-12, y+4);
}
void Prawn(int x, int y){
ellipse(x, y, r, r);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น