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