diff --git a/Makefile b/Makefile index a2e96ef..4abf7af 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ NAME = elefantes CC = gcc -LIBS = -lm -LIBS += $(shell ncursesw5-config --libs 2>/dev/null \ +LIBS != ncursesw5-config --libs 2>/dev/null \ || ncurses5-config --libs 2>/dev/null \ || ncursesw6-config --libs 2>/dev/null \ - || ncurses6-config --libs 2>/dev/null ) + || ncurses6-config --libs 2>/dev/null +LIBS += -lm -compile: +linux: $(CC) -o $(NAME) main.c distancia.c screen.c $(LIBS) + +netbsd: + $(CC) -o $(NAME) main.c distancia.c screen.c $(LIBS) -I/usr/pkg/include/ncursesw -I/usr/pkg/include/ diff --git a/TODO b/TODO index 319c3f0..3f54e90 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,4 @@ -Mellorar a xeneración da posición inicial dos elefantes. - +- Mellorar a xeneración da posición inicial dos elefantes. +- Poñer un contador de tempo para "competir". +- Facer que no fin saia un "popup" co tempo final e mensaxe de noraboa. +- https://www.linuxjournal.com/content/programming-color-ncurses diff --git a/screen.c b/screen.c index e0c14c2..e15aa46 100644 --- a/screen.c +++ b/screen.c @@ -4,6 +4,8 @@ #include "defs.h" #define ELEFANTES 6 +#define PLAYER_PAIR 1 + const int height = 40; const int width = 80; @@ -105,6 +107,14 @@ int capturas(WINDOW * win, int *esquinas){ } int screen() { + /* if (has_colors() == FALSE) { */ + /* endwin(); */ + /* printf("Your terminal does not support color\n"); */ + /* exit(1); */ + /* } */ + start_color(); + init_pair(PLAYER_PAIR, COLOR_RED, COLOR_MAGENTA); + int capt = 0; //capturas initscr(); @@ -125,6 +135,7 @@ int screen() { box(win, 0, 0); int* esquinasCaja = cuadra(win, width, height); + wrefresh(win); /* struct coord cazador = {height/3,width/2}; */ struct coord cazador = {10,10}; @@ -150,6 +161,7 @@ int screen() { // Movemento int c = wgetch(win); + attron(COLOR_PAIR(PLAYER_PAIR)); switch(c){ case KEY_UP: /* mvwprintw(win, 1, 1, "up"); */ @@ -188,6 +200,7 @@ int screen() { } break; } + attroff(COLOR_PAIR(PLAYER_PAIR)); // IA :D for(int i = 0; i < ELEFANTES; i++){