标签:Plan 简单 code getch add bre getc curses main
#include<stdlib.h> #include<ncurses,h> #define plane ‘*‘ char plane(int x,int y); int main() { int x = 5; int y = 10; char ch; initscr(); cbreak(); noecho(); clear(); do { clear(); picture(x,y); ch = getch(); switch(ch) { case ‘w‘: picture(x,y); y = y - 1; break; case ‘s‘: picture(x,y); y = y - 1; break; case ‘a‘: picture(x,y); x = x - 1; break; case ‘d‘: picture(x,y); x = x + 1; break; } }while(ch != ‘q‘); endwin(); exit(0); } char plane(int x,int y) { int i; for(i = 0;i<y;i++) { mvprintw(i,x,"%c",‘|‘); refresh(); } mvaddch(y,x,PLANE); mvaddch(y+1,x-2,PLANE); mvaddch(y+1,x-1,PLANE); mvaddch(y+1,x,PLANE); mvaddch(y+1,x+1,PLANE); mvaddch(y+1,x+2,PLANE); mvaddch(y+2,x-1,PLANE); mvaddch(y+2,x+1,PLANE); }
标签:Plan 简单 code getch add bre getc curses main
原文地址:https://www.cnblogs.com/zhongllmm/p/14281541.html