#include <ncurses.h>
int main()
{
char cur;
int row, col;
int x=2, ch, y=3;
initscr();
keypad(stdscr, TRUE);
getmaxyx(stdscr,row,col);
noecho();
move(y,x);
getch();
ch=getch();
printw("%c", cur);
//ch=getch();
while(ch!='q')
{
if(ch==KEY_LEFT)
x=x-1;
else if(ch==KEY_RIGHT)
x=x+1;
else if(ch==KEY_UP)
y=y-1;
else if(ch==KEY_DOWN)
y=y+1;
move(y,x);
getch();
ch=getch();
printw("%c", cur);
//ch=getch();
}
endwin();
return 0;
}
int main()
{
char cur;
int row, col;
int x=2, ch, y=3;
initscr();
keypad(stdscr, TRUE);
getmaxyx(stdscr,row,col);
noecho();
move(y,x);
getch();
ch=getch();
printw("%c", cur);
//ch=getch();
while(ch!='q')
{
if(ch==KEY_LEFT)
x=x-1;
else if(ch==KEY_RIGHT)
x=x+1;
else if(ch==KEY_UP)
y=y-1;
else if(ch==KEY_DOWN)
y=y+1;
move(y,x);
getch();
ch=getch();
printw("%c", cur);
//ch=getch();
}
endwin();
return 0;
}
0 comments:
Post a Comment