Browse Source

Write dropPiece function

remotes/origin/Ahmad
fdai7726 11 months ago
parent
commit
d796abbae3
  1. 12
      src/main/c/VierGewinnt.c

12
src/main/c/VierGewinnt.c

@ -138,3 +138,15 @@ void clearScreen() {
int isColumnFull(char board[ROWS][COLS], int col) { int isColumnFull(char board[ROWS][COLS], int col) {
return (board[0][col] != ' '); return (board[0][col] != ' ');
} }
//Write dropPiece function
int dropPiece(char board[ROWS][COLS], int col, char player) {
for (int i = ROWS - 1; i >= 0; i--) {
if (board[i][col] == ' ') {
board[i][col] = player;
return 1;
}
}
return 0; // Column is full
}
Loading…
Cancel
Save