diff options
Diffstat (limited to 'src/life.c')
| -rw-r--r-- | src/life.c | 21 |
1 files changed, 13 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; |
