0

我已经接近了,但我就是想不通。我在 Java 方面不是很好。我知道缺少的 B 和 W 在那里,只是它们与背景颜色相同。如果有人可以提供帮助,那就太好了。

public class checktest2 { 

    public static void main(String[] args) { 
        int N = 8;
        StdDraw.setXscale(0, 8);
        StdDraw.setYscale(0, 8);

        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if ( (i % 2) == (j % 2) )
                    StdDraw.setPenColor(StdDraw.WHITE);
                else 
                    StdDraw.setPenColor(StdDraw.BLACK);
                StdDraw.filledSquare(i + 0.5, j + 0.5, 0.5);
            }

            for (int j = 0; j < 8; j++) {

                  if ( (i % 2) == (j % 2) )
                    StdDraw.text(i + 0.5, j + 0.5, "W");
                  else
                    StdDraw.text(i + 0.5, j + 0.5, "B");
            }

        }
        StdDraw.show();
    }

}
4

1 回答 1

0

Right, if you try to display a black character on a black background, that is going to be really hard to read.

Why don't you just select slightly different colors for the squares, so the "pieces" stand out better. Just like other programs do for their chess graphics.

Check this page, for example:

http://www.tim-mann.org/xboard.html

于 2013-03-24T09:55:02.277 回答