Skip to content

Commit

Permalink
removed screen flicker on rapid input
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingpeakock committed Dec 29, 2020
1 parent 5429480 commit 0818a32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ libcurses or curses instead. If it still doesn't work use the -lncurses flag ins
of -lncursesw when compiling.

## Screenshots
![new game](https://imgur.com/awu4dbQ.png)
![Same game with pencil marks, a couple boxes filled in and a mistake](https://imgur.com/ooYHXm0.png)
![Same game after check board has been called](https://imgur.com/vF97N1b.png)
![new game](https://i.imgur.com/tdfuKdU.png)
![same game played a little](https://imgur.com/ooYHXm0.png)
![same game with check](https://imgur.com/vF97N1b.png)
![completed game]()

## Generate or Solve Sudoku Puzzles
You can use the Generator files and Solver files to generate
Expand Down
37 changes: 20 additions & 17 deletions src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,37 @@ Window::~Window() {
}

void Window::printBoard() {
int oldRows = windowRows;
int oldCols = windowCols;
getmaxyx(stdscr, windowRows, windowCols);
bool resize = (oldRows != windowRows || oldCols != windowCols);

boardTop = (windowRows - BoardRows) / 2;
boardLeft = (windowCols - BoardCols) / 2;
int gridTop = boardTop + 1;
int gridLeft = boardLeft + 2;

clear();

if (windowRows < BoardRows || windowCols < BoardCols) {
char error[] = "Not enough space to draw board";
mvprintw(windowRows / 2, (windowCols - strlen(error)) / 2, "%s", error);
refresh();
return;
}

if (windowRows - BoardRows > 3) {
attron(A_BOLD | A_UNDERLINE);
char title[] = "Console Sudoku";
mvprintw(boardTop - 3, (windowCols - strlen(title)) / 2, "%s", title);
attroff(A_BOLD | A_UNDERLINE);
if (resize) {
clear();
if (windowRows < BoardRows || windowCols < BoardCols) {
char error[] = "Not enough space to draw board";
mvprintw(windowRows / 2, (windowCols - strlen(error)) / 2, "%s", error);
refresh();
return;
}
if (windowRows - BoardRows > 3) {
attron(A_BOLD | A_UNDERLINE);
char title[] = "Console Sudoku";
mvprintw(boardTop - 3, (windowCols - strlen(title)) / 2, "%s", title);
attroff(A_BOLD | A_UNDERLINE);
}
printBoxes();
printInstructions();
printCoords();
}

printBoxes();
printPencil();
printNumbs();
printInstructions();
printCoords();
printMode();
printCursor();
refresh();
Expand Down

0 comments on commit 0818a32

Please sign in to comment.