#include #include "curses.h" #include "../player.h" #include "../game.h" #include "../wall.h" #include "../main.h" #include "../common.h" /* Acceptable colors for foreground and background (from manpage, curs_color): COLOR_BLACK COLOR_RED COLOR_GREEN COLOR_YELLOW COLOR_BLUE COLOR_MAGENTA COLOR_CYAN COLOR_WHITE Acceptable attributes (from manpage, curs_attr): A_NORMAL Normal display (no highlight) A_STANDOUT Best highlighting mode of the terminal. A_UNDERLINE Underlining A_REVERSE Reverse video A_BLINK Blinking A_DIM Half bright A_BOLD Extra bright or bold A_PROTECT Protected mode A_INVIS Invisible or blank mode A_ALTCHARSET Alternate character set A_CHARTEXT Bit-mask to extract a character */ CursesTile ascii_walls[] = { {'#', COLOR_WHITE, COLOR_BLACK, 0}, // 0=STONE_WALL {'#', COLOR_YELLOW, COLOR_BLACK, 0}, // 1=WOOD_WALL {'#', COLOR_WHITE, COLOR_BLACK, A_BOLD} // 2=STEEL_WALL }; int interfaceInit() { // initialize ncurses library if ((screen = initscr()) == NULL) { perror("initscr() error'd"); return ERROR; } original_cursor = curs_set(0); // store original cursor position for restore and hide cursor keypad(screen, TRUE); // enable arrow keys/keypad noecho(); // turn off key echoing nonl(); // do not do NL->CR/NL on output cbreak(); // Handle char presses immediately, do not wait for \n if (has_colors()) { start_color(); // set up all possible color pairs using COLORS as our max (8 default) int x, y; for (x=0;xfg * COLORS + temp->bg; //attron(COLOR_PAIR(color) | temp->attr); mvwaddch(screen, step_y, step_x, ascii_walls[map_matrix[step_x][step_y].tile[0]->id].ch); //attroff(COLOR_PAIR(color) | temp->attr); } else { mvwaddch(screen, step_y, step_x, ' '); } step_y++; // move down } step_x++; // move right } // draw player last mvwaddch(screen, player.y, player.x, '@'); refresh(); } void interfaceClose() { delwin(screen); endwin(); refresh(); }