Guest User

Ido Yehieli

a guest
Oct 11th, 2008
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <curses.h>
  2.  
  3. char *map[]={
  4. "***************",
  5. "* * *",
  6. "* *",
  7. "* *** ****",
  8. "**** *** * *",
  9. "* * *",
  10. "* * *",
  11. "* *",
  12. "* * *",
  13. "***************"
  14. };
  15.  
  16. main() {
  17. keypad(initscr(),1);
  18. int y=1;
  19. int x=1;
  20. int c;
  21. while('q'!=(c=getch())){
  22. for(int yy=0;yy<10;yy++)
  23. for(int xx=0;xx<15;xx++)
  24. mvaddch(yy,xx,map[yy][xx]);
  25. if(KEY_UP==c && ' '==map[y-1][x])
  26. y--;
  27. if(KEY_DOWN==c && ' '==map[y+1][x])
  28. y++;
  29. if(KEY_LEFT==c && ' '==map[y][x-1])
  30. x--;
  31. if(KEY_RIGHT==c && ' '==map[y][x+1])
  32. x++;
  33. mvaddch(y,x,'@');
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment