diff --git a/Makefile b/Makefile index 4453758..de42d2c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC ?= clang CFLAGS += -g -Wall -Wextra LFLAGS += -DEFINES := -DVT100 $(shell pkg-config --cflags sdl2) +DEFINES := -DINVERT_COLORS -DVT100 $(shell pkg-config --cflags sdl2) PROGRAM := 2048 C_FILES := $(wildcard src/*.c) diff --git a/src/gfx_curses.c b/src/gfx_curses.c index d9e45a7..8529866 100644 --- a/src/gfx_curses.c +++ b/src/gfx_curses.c @@ -2,6 +2,7 @@ #include #include #include "gfx.h" +#include "merge.h" #define NUMBER_OF_COLORS 7 @@ -33,6 +34,15 @@ struct gfx_state* gfx_init(struct gamestate *g) if (g->opts->enable_color && has_colors()) { start_color(); +#ifdef INVERT_COLORS + init_pair(0, 0, 1); + init_pair(1, 0, 2); + init_pair(2, 0, 3); + init_pair(3, 0, 4); + init_pair(4, 0, 5); + init_pair(5, 0, 6); + init_pair(6, 0, 7); +#else init_pair(0, 1, 0); init_pair(1, 2, 0); init_pair(2, 3, 0); @@ -40,6 +50,7 @@ struct gfx_state* gfx_init(struct gamestate *g) init_pair(4, 5, 0); init_pair(5, 6, 0); init_pair(6, 7, 0); +#endif } return s; @@ -65,7 +76,7 @@ void gfx_draw(struct gfx_state *s, struct gamestate *g) for (x = 0; x < g->opts->grid_width; ++x) { if (g->grid[x][y]) { wattron(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS)); - mvwprintw(s->window, ypos, xpos, "%*ld", g->print_width, merge_value(g->grid[x][y])); + mvwprintw(s->window, ypos, xpos, "%-*ld", g->print_width, merge_value(g->grid[x][y])); wattroff(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS)); mvwprintw(s->window, ypos, xpos + g->print_width, " |"); } diff --git a/src/highscore.c b/src/highscore.c index 117092d..1f3fec6 100644 --- a/src/highscore.c +++ b/src/highscore.c @@ -56,6 +56,7 @@ void highscore_reset(void) printf("Are you sure you want to reset your scores? Y(es) or N(o)\n"); while (1) { + /* fgets is used to avoid queuing that may occur with getchar */ fgets(resp, resp_length, stdin); string_to_lower(resp);