MeehoweCK

Untitled

Dec 21st, 2020
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. void ruch()
  7. {
  8.     char komenda;
  9.     while(true)
  10.     {
  11.         do
  12.         {
  13.             komenda = getch();
  14.             komenda = toupper(komenda);
  15.         } while(komenda != 'A' && komenda != 'S' && komenda != 'D' && komenda != 'W');
  16.         switch(komenda)
  17.         {
  18.         case 'A':
  19.             cout << "w lewo\n";
  20.             break;
  21.         case 'W':
  22.             cout << "w gore\n";
  23.             break;
  24.         case 'D':
  25.             cout << "w prawo\n";
  26.             break;
  27.         case 'S':
  28.             cout << "w dol\n";
  29.         }
  30.     }
  31. }
  32.  
  33. int main()
  34. {
  35.     ruch();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment