Created
September 14, 2014 04:48
-
-
Save grigory51/e2a4905467a5627c1439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ncurses.h> | |
#include <signal.h> | |
#include <stdlib.h> | |
#include "game.h" | |
static void finish(int sig); | |
int main(int argc, const char * argv[]) { | |
initscr(); | |
raw(); | |
noecho(); | |
keypad(stdscr, true); | |
start_color(); | |
curs_set(FALSE); | |
refresh(); | |
WINDOW * main = newwin(LINES-20, COLS-50, 0, 0); | |
wrefresh(main); | |
init_pair(5, COLOR_RED, COLOR_RED); | |
wbkgd(main, COLOR_PAIR(5)); | |
wrefresh(main); | |
enum arrows { | |
DOWN = 258, | |
UP = 259, | |
LEFT = 260, | |
RIGTH = 261 | |
}; | |
int ch; | |
int x = 0, y = 0; | |
while ((ch = getch()) != 'q') { | |
switch (ch) { | |
case DOWN: | |
y++; | |
break; | |
case UP: | |
y--; | |
break; | |
case LEFT: | |
x--; | |
break; | |
case RIGTH: | |
x++; | |
break; | |
default: | |
continue; | |
break; | |
} | |
mvwin(main, y, x); | |
wrefresh(main); | |
refresh(); | |
} | |
endwin(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment