Advertisement
UnlimitedSupply

Controllable Character

Jun 19th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <unistd.h>
  3. using namespace std;
  4.  
  5. int Right = 0;
  6. int RighterOne;
  7. int RighterTwo;
  8. int Up = 0;
  9. int Upper;
  10. string Answer;
  11. int main() {
  12.     cout << "W A S D WA AS WD SD Return End\n";
  13.     cout << "\n";
  14.     sleep(5);
  15.     do {
  16.         for (int x = 40; x >= 0; x--) {
  17.             cout << "\n";
  18.         }
  19.         if (Up < 0) {
  20.             Up = 0;
  21.         }
  22.         if (Right < 0) {
  23.             Right = 0;
  24.         }
  25.         RighterOne = Right;
  26.         RighterTwo = Right;
  27.         Upper = Up;
  28.         for (RighterOne; RighterOne >= 0; RighterOne--) {
  29.             cout << " ";
  30.         }
  31.         cout << ". .\n";
  32.         for (RighterTwo; RighterTwo >= 0; RighterTwo--) {
  33.             cout << " ";
  34.         }
  35.         cout << " - \n";
  36.         for (Upper; Upper >= 0; Upper--) {
  37.             cout << "\n";
  38.         }
  39.         cin >> Answer;
  40.         if (Answer == "A" || Answer == "a") {
  41.             Right--;
  42.         } else if (Answer == "D" || Answer == "d") {
  43.             Right++;
  44.         } else if (Answer == "W" || Answer == "w") {
  45.             Up++;
  46.         } else if (Answer == "S" || Answer == "s") {
  47.             Up--;
  48.         } else if (Answer == "AS" || Answer == "as" || Answer == "SA" || Answer == "sa") {
  49.             Right--;
  50.             Up--;
  51.         } else if (Answer == "WA" || Answer == "wa" || Answer == "AW" || Answer == "aw") {
  52.             Right--;
  53.             Up++;
  54.         } else if (Answer == "WD" || Answer == "wd" || Answer == "DW" || Answer == "dw") {
  55.             Up++;
  56.             Right++;
  57.         } else if (Answer == "SD" || Answer == "sd" || Answer == "DS" || Answer == "ds") {
  58.             Up--;
  59.             Right++;
  60.         } else if (Answer == "Return" || Answer == "return") {
  61.             Up = 0;
  62.             Right = 0;
  63.         }
  64.     } while (Answer != "End" && Answer != "end");
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement