0
我想移動一個點在我想在Linux終端的方向,但它沒有發生我希望我不能找到我失蹤的地方。 這裏是我的code`在我想要的方向移動一個點使用Ncurses
#include<iostream>
#include<ncurses.h>
using namespace std;
int main()
{ int x=10;
int y=10;
int z=3;
initscr();
for(;;)
{ WINDOW*win=newwin(75, 75, 3, 2);
wrefresh(win);
wmove(win,y,x);
raw();
noecho();
wprintw(win,"*");
wrefresh(win);
usleep(600000);
wmove(win,y,x);
wprintw(win," "); //prints space at the coordinates of point where it has earlier print *
wrefresh(win);
nodelay(stdscr,TRUE);
z=getch();
switch(z)
{
case 5:y+=1;
break;
case 2:y-=1;
break;
case 3:x+=1;
break;
case 1:x-=1;
break;
}
}
endwin();
return 0;
}