tty-solitaire/src/ttysolitaire.c

54 lines
1.2 KiB
C
Raw Normal View History

#include <ncurses.h>
2011-06-03 06:09:14 +00:00
#include <locale.h>
2011-06-03 05:48:26 +00:00
2011-06-03 06:22:48 +00:00
#include "draw.h"
#include "game.h"
#include "keyboard.h"
const char *program_name;
int main(int argc, const char *argv[]) {
program_name = *argv;
int key;
2011-06-03 06:09:14 +00:00
setlocale(LC_ALL, "en_US.utf-8"); /* Support unicode characters. */
initscr();
raw(); /* Disable line buffers. */
noecho();
keypad(stdscr, TRUE); /* Enable arrow keys. */
start_color(); /* I want colors. */
curs_set(FALSE); /* Invisible cursor. */
set_escdelay(0);
assume_default_colors(COLOR_WHITE, COLOR_GREEN);
init_pair(1, COLOR_BLACK, COLOR_WHITE);
init_pair(2, COLOR_RED, COLOR_WHITE);
init_pair(3, COLOR_WHITE, COLOR_BLUE);
init_pair(4, COLOR_WHITE, COLOR_GREEN);
2011-06-03 06:22:48 +00:00
draw_greeting();
while (key != KEY_SPACEBAR) {
switch (key = getch()) {
2011-02-06 06:14:17 +00:00
case KEY_SPACEBAR:
initialize_game();
break;
case 'q':
case 'Q':
2011-06-03 06:09:14 +00:00
endwin();
return(0);
}
}
while (1) {
if ((key = getch()) == 'q' || key == 'Q') {
2011-06-03 06:09:14 +00:00
endwin();
2011-02-10 01:50:24 +00:00
end_game();
2011-06-03 06:09:14 +00:00
return(0);
} else {
handle_keyboard_event(key);
}
}
return(0);
}