Compare commits
No commits in common. "bbaf2f50f9c5eac055672895ad8cca862a0ddcd7" and "cf2fa8a9c22791d39799bc1ee834ed4aea2de76c" have entirely different histories.
bbaf2f50f9
...
cf2fa8a9c2
34
src/main.cpp
34
src/main.cpp
@ -8,15 +8,6 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "Board.h"
|
#include "Board.h"
|
||||||
#ifndef _WIN32
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
struct winsize w;
|
|
||||||
void handleSIGWINCH(int sig)
|
|
||||||
{
|
|
||||||
ioctl(STDIN_FILENO, TIOCGWINSZ, &w);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_TIME 60
|
#define MAX_TIME 60
|
||||||
|
|
||||||
@ -42,16 +33,8 @@ void startGame(Board &board)
|
|||||||
|
|
||||||
while (gameRunning)
|
while (gameRunning)
|
||||||
{
|
{
|
||||||
|
|
||||||
usleep((1000 / MAX_TIME) * 1000);
|
usleep((1000 / MAX_TIME) * 1000);
|
||||||
#ifndef _WIN32
|
|
||||||
if((w.ws_row < boardSize.x + 3 )||( w.ws_col < boardSize.y + 2)) {
|
|
||||||
mvprintw(w.ws_col/2, w.ws_row/2, "Your terminal is too small:");
|
|
||||||
mvprintw(w.ws_col / 2 + 1, w.ws_row/2, "Current size: %dx%d", w.ws_row, w.ws_col);
|
|
||||||
mvprintw(w.ws_col / 2 + 2, w.ws_row/2, "Min size: %dx%d", boardSize.x + 3, boardSize.y + 2);
|
|
||||||
refresh();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (board.isGameOver() || board.isGameWon())
|
if (board.isGameOver() || board.isGameWon())
|
||||||
{
|
{
|
||||||
gameRunning = false;
|
gameRunning = false;
|
||||||
@ -178,9 +161,6 @@ void startGame(Board &board)
|
|||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
exit(0);
|
exit(0);
|
||||||
echo();
|
|
||||||
cbreak();
|
|
||||||
endwin();
|
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
if (!somethingHasBeenDone)
|
if (!somethingHasBeenDone)
|
||||||
@ -284,9 +264,6 @@ void startGame(Board &board)
|
|||||||
startGame(newBoard);
|
startGame(newBoard);
|
||||||
} else if(c == 'q') {
|
} else if(c == 'q') {
|
||||||
exit(0);
|
exit(0);
|
||||||
echo();
|
|
||||||
cbreak();
|
|
||||||
endwin();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -314,9 +291,6 @@ void startGame(Board &board)
|
|||||||
startGame(newBoard);
|
startGame(newBoard);
|
||||||
} else if(c == 'q') {
|
} else if(c == 'q') {
|
||||||
exit(0);
|
exit(0);
|
||||||
echo();
|
|
||||||
cbreak();
|
|
||||||
endwin();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -324,14 +298,12 @@ void startGame(Board &board)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
signal(SIGWINCH, handleSIGWINCH);
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
cbreak();
|
cbreak();
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
nodelay(stdscr, TRUE);
|
nodelay(stdscr, TRUE);
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
|
||||||
|
|
||||||
start_color();
|
start_color();
|
||||||
init_pair(1, COLOR_BLUE, COLOR_BLACK);
|
init_pair(1, COLOR_BLUE, COLOR_BLACK);
|
||||||
@ -362,9 +334,9 @@ int main()
|
|||||||
attroff(A_REVERSE);
|
attroff(A_REVERSE);
|
||||||
mvprintw(3, 2, choice == 1 ? "" : "Intermediate (16x16, 40 mines)");
|
mvprintw(3, 2, choice == 1 ? "" : "Intermediate (16x16, 40 mines)");
|
||||||
attron(A_REVERSE);
|
attron(A_REVERSE);
|
||||||
mvprintw(4, 2, choice == 2 ? "Expert (30x16, 99 mines)" : "");
|
mvprintw(4, 2, choice == 2 ? "Expert (16x30, 99 mines)" : "");
|
||||||
attroff(A_REVERSE);
|
attroff(A_REVERSE);
|
||||||
mvprintw(4, 2, choice == 2 ? "" : "Expert (30x16, 99 mines)");
|
mvprintw(4, 2, choice == 2 ? "" : "Expert (16x30, 99 mines)");
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
int ch = getch();
|
int ch = getch();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user