Invert colorscheme by default on ncurses version for more distinct squares

This commit is contained in:
Tiehuis 2015-02-23 16:18:41 +13:00
parent 1e2b2b76ac
commit 622a4b46ef
3 changed files with 14 additions and 2 deletions

View File

@ -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)

View File

@ -2,6 +2,7 @@
#include <ncurses.h>
#include <unistd.h>
#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, " |");
}

View File

@ -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);