Alter looping variables to better describe intent

This commit is contained in:
Tiehuis 2014-12-06 11:20:13 +13:00
parent 387f37a64a
commit 2b1d230330

View File

@ -45,12 +45,12 @@ void draw_screen(struct gamestate *g)
mvwprintw(gamewin, 1, 0, "HISCR: %d\n", g->score_high); mvwprintw(gamewin, 1, 0, "HISCR: %d\n", g->score_high);
ITER(g->opts->grid_width*(g->print_width + 2) + 1, waddch(gamewin, '-')); ITER(g->opts->grid_width*(g->print_width + 2) + 1, waddch(gamewin, '-'));
int i, j, xps = 0, yps = 3; int x, y, xps = 0, yps = 3;
for (i = 0; i < g->opts->grid_width; i++, xps = 0, yps++) { for (y = 0; y < g->opts->grid_height; y++, xps = 0, yps++) {
mvwprintw(gamewin, yps, xps++, "|"); mvwprintw(gamewin, yps, xps++, "|");
for (j = 0; j < g->opts->grid_height; j++) { for (x = 0; x < g->opts->grid_width; x++) {
if (g->grid[j][i]) { if (g->grid[x][y]) {
mvwprintw(gamewin, yps, xps, "%*d", g->print_width, g->grid[j][i]); mvwprintw(gamewin, yps, xps, "%*d", g->print_width, g->grid[x][y]);
mvwprintw(gamewin, yps, xps + g->print_width, " |"); mvwprintw(gamewin, yps, xps + g->print_width, " |");
} }
else { else {
@ -99,12 +99,12 @@ void draw_screen(struct gamestate *g)
// alter this grid_size + 1 to match abitrary grid size // alter this grid_size + 1 to match abitrary grid size
ITER(g->opts->grid_width, printf("------")); ITER(g->opts->grid_width, printf("------"));
printf("-\n"); printf("-\n");
int i, j; int x, y;
for (i = 0; i < g->opts->grid_height; i++) { for (y = 0; y < g->opts->grid_height; y++) {
printf("|"); printf("|");
for (j = 0; j < g->opts->grid_width; j++) { for (x = 0; x < g->opts->grid_width; x++) {
if (g->grid[j][i]) if (g->grid[x][y])
printf("%*ld |", 4, g->grid[j][i]); printf("%*ld |", 4, g->grid[x][y]);
else else
printf(" |"); printf(" |");
} }