summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. 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)
commit5d2263ec819ad03933a113d926bfc88cd1748f8b (patch)
treedec75e032c5b76aa2927dc358bbae64762acaf4b
parenta7a3a38c2f980aa79bd54b1233fbf5c7f932e5f6 (diff)
downloadcgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.zip
cgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.tar.gz
cgol-5d2263ec819ad03933a113d926bfc88cd1748f8b.tar.bz2
Separate cell printing into a new function.
-rw-r--r--src/cgol.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cgol.c b/src/cgol.c
index b6bbd58..d4411d0 100644
--- a/src/cgol.c
+++ b/src/cgol.c
@@ -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] "