|
サイズ: 459
コメント:
|
サイズ: 547
コメント:
|
| 削除された箇所はこのように表示されます。 | 追加された箇所はこのように表示されます。 |
| 行 8: | 行 8: |
| public void paintComponent(Graphics g) { ... |
|
| 行 10: | 行 13: |
| } | |
| 行 13: | 行 17: |
| void shokika() { ... |
|
| 行 27: | 行 34: |
| } |
ばらばらにする
int spx, spy;
public void paintComponent(Graphics g)
{
...
g.setColor(Color.lightGray);
g.fillRect(spx*haba, spy*haba, haba, haba);
} void shokika()
{
...
spx = yoko-1;
spy = tate-1;
for (cnt = 0; cnt < (tate*yoko*2); ) // 偶数回置換
{
x = (int)(Math.random() * yoko);
y = (int)(Math.random() * tate);
if(x != spx || y != spy)
{
ban[spx][spy] = ban[x][y];
spx = x;
spy = y;
cnt++;
}
}
}