proba colores

This commit is contained in:
serxoz 2021-11-17 11:51:45 +01:00
parent b42ac4b8a1
commit e46e5fdc02
3 changed files with 24 additions and 6 deletions

View File

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

6
TODO
View File

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

View File

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