Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <curses.h>
- char *map[]={
- "***************",
- "* * *",
- "* *",
- "* *** ****",
- "**** *** * *",
- "* * *",
- "* * *",
- "* *",
- "* * *",
- "***************"
- };
- main() {
- keypad(initscr(),1);
- int y=1;
- int x=1;
- int c;
- while('q'!=(c=getch())){
- for(int yy=0;yy<10;yy++)
- for(int xx=0;xx<15;xx++)
- mvaddch(yy,xx,map[yy][xx]);
- if(KEY_UP==c && ' '==map[y-1][x])
- y--;
- if(KEY_DOWN==c && ' '==map[y+1][x])
- y++;
- if(KEY_LEFT==c && ' '==map[y][x-1])
- x--;
- if(KEY_RIGHT==c && ' '==map[y][x+1])
- x++;
- mvaddch(y,x,'@');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment