diff options
author | P. J. McDermott <pjm@nac.net> | 2011-12-13 01:07:35 (EST) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2011-12-13 01:07:35 (EST) |
commit | 5d2263ec819ad03933a113d926bfc88cd1748f8b (patch) | |
tree | dec75e032c5b76aa2927dc358bbae64762acaf4b /src | |
parent | a7a3a38c2f980aa79bd54b1233fbf5c7f932e5f6 (diff) | |
download | cgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.zip cgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.tar.gz cgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.tar.bz2 |
Separate cell printing into a new function.
Diffstat (limited to 'src')
-rw-r--r-- | src/cgol.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -25,11 +25,12 @@ #include <unistd.h> #include <curses.h> -void usage(const char *invocation); void init_curses(); void init_game(); void fini_game(); void fini_curses(); +void print_cell(int i, int j); +void usage(const char *invocation); static int width, height; static double seedprob; @@ -142,7 +143,7 @@ init_game() /* Print the grid. */ for (i = 0; i < height; ++i) { for (j = 0; j < width; ++j) { - mvprintw(1 + i, 1 + j * 2, "%c", grid_cur[i * width + j] ? 'o' : ' '); + print_cell(i, j); } } } @@ -161,6 +162,12 @@ fini_curses() } void +print_cell(int i, int j) +{ + mvprintw(1 + i, 1 + j * 2, "%c", grid_cur[i * width + j] ? 'o' : ' '); +} + +void usage(const char *invocation) { printf("Usage: %s [-w WIDTH] [-h HEIGHT] [-s SEEDPROB] [-r RATE] " |