hasty bugfix and moved board functions to own directory

This commit is contained in:
2024-12-15 12:07:25 +02:00
parent 66238756d6
commit be6dfe712c
6 changed files with 81 additions and 15 deletions

View File

@@ -39,6 +39,24 @@ void sleep_ms(const int ms) {
usleep(ms * 1000);
}
void setBoardBorders(char board[][brdInfo.x]) {
for (int i = 0; i < brdInfo.y; i++) {
for (int j = 0; j < brdInfo.x; j++) {
if (i == 0 || i == brdInfo.y - 1)
board[i][j] = '-';
else if (j == 0 || j == brdInfo.x - 1)
board[i][j] = '|';
else
board[i][j] = ' ';
}
}
board[0][0] = '+';
board[brdInfo.y - 1][0] = '+';
board[0][brdInfo.x - 1] = '+';
board[brdInfo.y - 1][brdInfo.x - 1] = '+';
}
void printBoard(char board[][brdInfo.x]) {
for (int i = 0; i < brdInfo.y; i++) {
for (int j = 0; j < brdInfo.x; j++) {

View File

@@ -10,6 +10,7 @@ int randomInt(const int start, const int end, const unsigned int seed);
int randomX(const clock_t initClock);
int randomY(const clock_t initClock);
void sleep_ms(const int ms);
void setBoardBorders(char board[][brdInfo.x]);
void printBoard(char board[][brdInfo.x]);
#endif // UTILS_H_