Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. void ruch(Snake *g, Snake *h){
  2. while (_kbhit()){
  3. switch (_getch()){
  4. case lewo:
  5. if (g->y>1){
  6. while (1){
  7. putcharXY(g->x, g->y, 32);
  8. g->y--;
  9. putcharXY(g->x, g->y, 176);
  10. Sleep(500);
  11. if (_getch){
  12. ruch(g, h);
  13. }
  14. }
  15. }
  16. break;
  17. case prawo:
  18. if (g->y<width - 2){
  19. while (1){
  20. putcharXY(g->x, g->y, 32);
  21. g->y++;
  22. putcharXY(g->x, g->y, 176);
  23. Sleep(500);
  24. if (_getch){
  25. ruch(g, h);
  26. }
  27. }
  28. }
  29. break;
  30. case gora:
  31. if (g->x>1){
  32. while (1){
  33. putcharXY(g->x, g->y, 32);
  34. g->x--;
  35. putcharXY(g->x, g->y, 176);
  36. Sleep(500);
  37. if (_getch){
  38. ruch(g, h);
  39. }
  40. }
  41. }
  42. break;
  43. case dol:
  44. if (g->x<height - 2){
  45. while (1){
  46. putcharXY(g->x, g->y, 32);
  47. g->x++;
  48. putcharXY(g->x, g->y, 176);
  49. Sleep(500);
  50. if (_getch){
  51. ruch(g, h);
  52. }
  53. }
  54. }
  55. break;
  56. case 'a':
  57. if (h->y>1){
  58. while (1){
  59. putcharXY(h->x, h->y, 32);
  60. h->y--;
  61. putcharXY(h->x, h->y, 178);
  62. Sleep(500);
  63. if (_getch){
  64. ruch(g, h);
  65. }
  66. }
  67. }
  68. break;
  69. case 'd':
  70. if (h->y<width - 2){
  71. while (1){
  72. putcharXY(h->x, h->y, 32);
  73. h->y++;
  74. putcharXY(h->x, h->y, 178);
  75. Sleep(500);
  76. if (_getch){
  77. ruch(g, h);
  78. }
  79. }
  80. }
  81. break;
  82. case 'w':
  83. if (h->x>1){
  84. while (1){
  85. putcharXY(h->x, h->y, 32);
  86. h->x--;
  87. putcharXY(h->x, h->y, 178);
  88. Sleep(500);
  89. if (_getch){
  90. ruch(g, h);
  91. }
  92. }
  93. }
  94. break;
  95. case 's':
  96. if (h->x<height - 2){
  97. while (1){
  98. putcharXY(h->x, h->y, 32);
  99. h->x++;
  100. putcharXY(h->x, h->y, 178);
  101. Sleep(500);
  102. if (_getch){
  103. ruch(g, h);
  104. }
  105. }
  106. }
  107. break;
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement