board size change feature
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "utils.h"
|
||||
#include "../globals.h"
|
||||
|
||||
extern char board[BRD_SIZE_Y][BRD_SIZE_X];
|
||||
extern boardInfo brdInfo;
|
||||
extern playableBoardInfo plBrdInfo;
|
||||
|
||||
int randomInt(const int start, const int end, const unsigned int seed) {
|
||||
/*
|
||||
@@ -22,7 +22,7 @@ int randomX(const clock_t initClock) {
|
||||
int x;
|
||||
const unsigned int seed = clock() - initClock;
|
||||
for (int i = randomInt(0, 100, seed); ; i++) {
|
||||
x = randomInt(PL_BRD_XS, PL_BRD_XE, i);
|
||||
x = randomInt(plBrdInfo.xs, plBrdInfo.xe, i);
|
||||
if (x % 2 != 0)
|
||||
break;
|
||||
}
|
||||
@@ -32,16 +32,16 @@ int randomX(const clock_t initClock) {
|
||||
|
||||
int randomY(const clock_t initClock) {
|
||||
const unsigned int seed = clock() - initClock;
|
||||
return randomInt(PL_BRD_YS, PL_BRD_YE, seed);
|
||||
return randomInt(plBrdInfo.ys, plBrdInfo.ye, seed);
|
||||
}
|
||||
|
||||
void sleep_ms(const int ms) {
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
void printBoard() {
|
||||
for (int i = 0; i < BRD_SIZE_Y; i++) {
|
||||
for (int j = 0; j < BRD_SIZE_X; j++) {
|
||||
void printBoard(char board[][brdInfo.x]) {
|
||||
for (int i = 0; i < brdInfo.y; i++) {
|
||||
for (int j = 0; j < brdInfo.x; j++) {
|
||||
printf("%c", board[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
#define UTILS_H_
|
||||
|
||||
#include <time.h>
|
||||
#include "../globals.h"
|
||||
|
||||
extern boardInfo brdInfo;
|
||||
|
||||
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 printBoard();
|
||||
void printBoard(char board[][brdInfo.x]);
|
||||
|
||||
#endif // UTILS_H_
|
||||
|
||||
Reference in New Issue
Block a user