diff options
| author | Aiden Woodruff <aiden.woodruff@gmail.com> | 2019-09-18 22:44:20 -0500 |
|---|---|---|
| committer | Aiden Woodruff <aiden.woodruff@gmail.com> | 2019-09-18 22:44:20 -0500 |
| commit | 176647fc5eb719953aa3961f39b3311e3368ce6a (patch) | |
| tree | cf04f7a06fd9ccc3a8ce24b98fff87eadaeda164 | |
| parent | 46921bc5f613362cc8f3af8a285549232929af13 (diff) | |
| download | life-176647fc5eb719953aa3961f39b3311e3368ce6a.tar.gz life-176647fc5eb719953aa3961f39b3311e3368ce6a.tar.bz2 life-176647fc5eb719953aa3961f39b3311e3368ce6a.zip | |
Small changes
Correct division by 4 to division by 2
Refresh board as well after printing warranty
Erase screen after printing warranty (or it'll stay)
Don't use the tab character (`\t`)
endwin before deleting and erasing everything
Don't bother lowercasing everything
Clear the fancy rule input menu
| -rw-r--r-- | src/life.c | 21 | ||||
| -rw-r--r-- | src/menus.c | 2 |
2 files changed, 15 insertions, 8 deletions
| @@ -124,9 +124,9 @@ int main (int argc, char * argv[]) { | |||
| 124 | map = malloc((height * width)+1); | 124 | map = malloc((height * width)+1); |
| 125 | memset(map, 0, height * width + 1); | 125 | memset(map, 0, height * width + 1); |
| 126 | memset(map, deadcell, height * width); | 126 | memset(map, deadcell, height * width); |
| 127 | x = width >> 2; | 127 | x = width >> 1; // width / 2, should be optimized anyway |
| 128 | y = height >> 2; | 128 | y = height >> 1; // height / 2, should be optimized anyway |
| 129 | while (ch != 'q') { | 129 | while (ch != 'q' && ch != 'Q') { |
| 130 | foreach(werase, stdscr, board, stat_bar, entry); | 130 | foreach(werase, stdscr, board, stat_bar, entry); |
| 131 | if (playing == FALSE) { | 131 | if (playing == FALSE) { |
| 132 | // Numpad and arrow directions | 132 | // Numpad and arrow directions |
| @@ -202,9 +202,10 @@ int main (int argc, char * argv[]) { | |||
| 202 | foreach(werase, stdscr, board, stat_bar, entry); | 202 | foreach(werase, stdscr, board, stat_bar, entry); |
| 203 | stat_bar_print(stat_bar, "Press any key to return"); | 203 | stat_bar_print(stat_bar, "Press any key to return"); |
| 204 | print_copying_warranty(board); | 204 | print_copying_warranty(board); |
| 205 | foreach(wnoutrefresh, stdscr, entry, stat_bar); | 205 | foreach(wnoutrefresh, stdscr, entry, stat_bar, board); |
| 206 | doupdate(); | 206 | doupdate(); |
| 207 | getch(); | 207 | getch(); |
| 208 | foreach(werase, stdscr, stat_bar, board); | ||
| 208 | wtimeout(board, timeout_val); | 209 | wtimeout(board, timeout_val); |
| 209 | break; | 210 | break; |
| 210 | case CTRL('r'): | 211 | case CTRL('r'): |
| @@ -239,8 +240,13 @@ int main (int argc, char * argv[]) { | |||
| 239 | for (int i = 0; i < height; ++i) { | 240 | for (int i = 0; i < height; ++i) { |
| 240 | mvwaddnstr(board, i, 0, map + (i * width), width); | 241 | mvwaddnstr(board, i, 0, map + (i * width), width); |
| 241 | } | 242 | } |
| 242 | mvwchgat(board, y, x, 1, A_STANDOUT, COLOR_PAIR(0), NULL); | 243 | if (mvwchgat(board, y, x, 1, A_STANDOUT, COLOR_PAIR(0), NULL) == ERR) fprintf(stderr, "Error (mvwchgat)\n"); |
| 243 | stat_bar_print(stat_bar, "(%d, %d)\t\tGeneration: %d\t\tDelay Time: %d", x, y, generation, delaymax); | 244 | |
| 245 | // Emulate tabs | ||
| 246 | mvwprintw(stat_bar, 0, 0, "(%d, %d)", x, y); | ||
| 247 | mvwprintw(stat_bar, 0, 12, "Generation: %d", generation); | ||
| 248 | mvwprintw(stat_bar, 0, 30, "Delay Time: %d", delaymax); | ||
| 249 | mvwchgat(stat_bar, 0, 0, -1, A_STANDOUT, COLOR_PAIR(0), NULL); | ||
| 244 | foreach(wnoutrefresh, stdscr, board, entry, stat_bar); | 250 | foreach(wnoutrefresh, stdscr, board, entry, stat_bar); |
| 245 | doupdate(); | 251 | doupdate(); |
| 246 | if (playing == TRUE) { | 252 | if (playing == TRUE) { |
| @@ -252,12 +258,11 @@ int main (int argc, char * argv[]) { | |||
| 252 | } | 258 | } |
| 253 | } | 259 | } |
| 254 | ch = wgetch(board); | 260 | ch = wgetch(board); |
| 255 | ch = tolower(ch); | ||
| 256 | } | 261 | } |
| 262 | endwin(); | ||
| 257 | foreach(werase, stdscr, board, stat_bar, entry, rule_entry, rule_entry_box); | 263 | foreach(werase, stdscr, board, stat_bar, entry, rule_entry, rule_entry_box); |
| 258 | foreach(delwin, entry, stat_bar, board, rule_entry, rule_entry_box); | 264 | foreach(delwin, entry, stat_bar, board, rule_entry, rule_entry_box); |
| 259 | board = stat_bar = entry = rule_entry = rule_entry_box = NULL; | 265 | board = stat_bar = entry = rule_entry = rule_entry_box = NULL; |
| 260 | endwin(); | ||
| 261 | delwin(stdscr); | 266 | delwin(stdscr); |
| 262 | free(map); | 267 | free(map); |
| 263 | map = NULL; | 268 | map = NULL; |
diff --git a/src/menus.c b/src/menus.c index 7c2abd8..3909e73 100644 --- a/src/menus.c +++ b/src/menus.c | |||
| @@ -172,5 +172,7 @@ int fancy_rules (WINDOW * win, int ruleint, int speed) { | |||
| 172 | ch = wgetch(win); | 172 | ch = wgetch(win); |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| 175 | werase(win); | ||
| 176 | wrefresh(win); | ||
| 175 | return ruleint; | 177 | return ruleint; |
| 176 | } | 178 | } |
