Compare commits
No commits in common. "80a10a157ed1a37a86492557c028d0286433a669" and "a65787b674511e353e60abf94552725c7db0dfe9" have entirely different histories.
80a10a157e
...
a65787b674
24
src/main.cpp
24
src/main.cpp
@ -18,15 +18,13 @@ void startGame(Board &board)
|
|||||||
refresh();
|
refresh();
|
||||||
bool gameRunning = true;
|
bool gameRunning = true;
|
||||||
|
|
||||||
time_t startTime = 0;
|
time_t startTime = time(nullptr);
|
||||||
int elapsedTime = 0;
|
int elapsedTime = 0;
|
||||||
|
|
||||||
bool isPaused = false;
|
bool isPaused = false;
|
||||||
time_t startPauseTime = 0;
|
time_t startPauseTime = 0;
|
||||||
time_t pauseTime = 0;
|
time_t pauseTime = 0;
|
||||||
time_t totalpausetime = 0;
|
time_t totalpausetime = 0;
|
||||||
bool somethingHasBeenDone = false;
|
|
||||||
|
|
||||||
while (gameRunning)
|
while (gameRunning)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,7 +33,7 @@ void startGame(Board &board)
|
|||||||
{
|
{
|
||||||
gameRunning = false;
|
gameRunning = false;
|
||||||
}
|
}
|
||||||
if (!isPaused && somethingHasBeenDone)
|
if (!isPaused)
|
||||||
elapsedTime = difftime(time(NULL), startTime) - totalpausetime;
|
elapsedTime = difftime(time(NULL), startTime) - totalpausetime;
|
||||||
char flags[5];
|
char flags[5];
|
||||||
char tim[5];
|
char tim[5];
|
||||||
@ -86,9 +84,6 @@ void startGame(Board &board)
|
|||||||
displayChar = 'X';
|
displayChar = 'X';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPaused)
|
|
||||||
displayChar = '#';
|
|
||||||
|
|
||||||
if (x == cursorX && y == cursorY)
|
if (x == cursorX && y == cursorY)
|
||||||
{
|
{
|
||||||
attron(A_REVERSE);
|
attron(A_REVERSE);
|
||||||
@ -159,19 +154,9 @@ void startGame(Board &board)
|
|||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
if (!somethingHasBeenDone)
|
|
||||||
{
|
|
||||||
startTime = time(nullptr);
|
|
||||||
somethingHasBeenDone = true;
|
|
||||||
}
|
|
||||||
board.revealCellAt(cursorX, cursorY);
|
board.revealCellAt(cursorX, cursorY);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if (!somethingHasBeenDone)
|
|
||||||
{
|
|
||||||
startTime = time(nullptr);
|
|
||||||
somethingHasBeenDone = true;
|
|
||||||
}
|
|
||||||
if (board.getCellStateAt(cursorX, cursorY) == Cell::State::Flagged)
|
if (board.getCellStateAt(cursorX, cursorY) == Cell::State::Flagged)
|
||||||
{
|
{
|
||||||
minesLeft++;
|
minesLeft++;
|
||||||
@ -200,11 +185,6 @@ void startGame(Board &board)
|
|||||||
isPaused = !isPaused;
|
isPaused = !isPaused;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!somethingHasBeenDone)
|
|
||||||
{
|
|
||||||
startTime = time(nullptr);
|
|
||||||
somethingHasBeenDone = true;
|
|
||||||
}
|
|
||||||
auto neighbors = board.getNeighborsOf(cursorX, cursorY);
|
auto neighbors = board.getNeighborsOf(cursorX, cursorY);
|
||||||
for (const Cell &neighbor : neighbors)
|
for (const Cell &neighbor : neighbors)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user