I am making a game board and i would like to show the game board animation, The animation is a object dropping down like this,
time=0
○○○
○○○
○○○
○○○
time=1
●○○
○○○
○○○
○○○
time=2
●○○
●○○
○○○
○○○
time=3
●○○
●○○
●○○
○○○
time=4
●○○
●○○
●○○
●○○
for (int row = 0; row < ROW_MAX; row++) {
for (int col = 0; col < COLUMN_MAX; col++) {
TempBoard[row][col]= hollow;
}
}
drawBoard(TempBoard);
Thread.sleep(1000);
TempBoard[0][column] = solid;
drawBoard(TempBoard);
Thread.sleep(1000);
TempBoard[1][column] = solid;
drawBoard(TempBoard);
Thread.sleep(1000);
TempBoard[2][column] = solid;
drawBoard(TempBoard);
Thread.sleep(100);
TempBoard[3][column] = solid;
drawBoard(TempBoard);
Thread.sleep(1000);
But i cannot get what i want,it shows time=4 directly and missed the steps in time=0-3 what is the problem? How can i fix it? Or any other simple way to do it? Thankyou.
The drawBoard method:
public void drawBoard(Disc[][] updateBoard) {
Disc[][] tempBoard = updateBoard;
for (int row = 0; row < ROW_MAX; row++) {
for (int col = 0; col < COLUMN_MAX; col++) {
if (tempBoard[row][col] == hollow) {
//jbtBoard[row][col].setIcon(hollowImg);
System.out.println(hollow);
} else if (tempDisc[row][col] == solid) {
//jbtBoard[row][col].setIcon(solidImg);
System.out.println(solid);
}
}
}
然而, 在实施守则时,产出就好像:
time=0,1,2,3
○○○
○○○
○○○
○○○
time=4
●○○
●○○
●○○
●○○