|
|
在编一个curse程序中
#include <curses.h>
#define StartX 1
#define StartY 1
void initial();
main()
{
int x=StartX;
int y=StartY;
int ch;
initial();
box(stdscr,'|','-');
attron(A_REVERSE);
mvaddstr(0,20,"Curses Program");
attroff(A_REVERSE);
move(x,y);
x=0;y=0;
int vx = 1;
int vy = 2,i;
ch = getch();///
while(1){
ch=getch();////???在这里没有这语句就不正常为什么?
mvaddch(y,x,' ');
x+=vx;
y+=vy;
if(x>=80) vx = -1;
if(x<=0) vx=1;
if(y>=24) vy = -1;
if(y<=0) vy=1;
for(i=1;i<1000;i++){
}
mvaddch(y,x,'@');
}
}
void initial()
{
initscr();
cbreak();
nonl();
noecho();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
refresh();
} |
|