Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int input = -1, location = 0;
  6.  
  7. do
  8. {
  9. if (
  10. (
  11. (input != -1 && input != 2 && input != 4 && input != 6 && input != 8) ||
  12. (input == 2 && ((location & 2) == 2)) ||
  13. (input == 4 && ((location & 1) == 0)) ||
  14. (input == 6 && ((location & 1) == 1)) ||
  15. (input == 8 && ((location & 2) == 0))
  16. ) ? 0 * printf("Cannot move in this direction from this room.\r\n")
  17. : 1 + ((input == -1) ? 0 * printf("== Super Text Adventure ==\r\n") : 0)
  18. + 0 * (
  19. location = (input == 8) ? (location & 1) :
  20. ((input == 2) ? (location | 2) :
  21. ((input == 4) ? (location & 2) :
  22. ((input == 6) ? (location | 1) : location)))
  23. )
  24. )
  25. printf("---------\r\n| %c | %c |\r\n---------\r\n| %c | %c |\r\n---------\r\nYou are in room %d.\r\n%s\r\n",
  26. location == 0 ? 'X':' ',
  27. location == 1 ? 'X':' ',
  28. location == 2 ? 'X':' ',
  29. location == 3 ? 'X':'T',
  30. location + 1,
  31. location == 3 ? "You have found the treasure! You win!\r\n" :
  32. "Which direction would you like to move?\r\n[8] North\r\n[4] "
  33. "West\r\n[2] South\r\n[6] East\r\n[0] Exit\r\n<===========>");
  34.  
  35. } while ((location == 3 ? 0 : (1 + 0 * scanf("%u", &input))) && input != 0);
  36. }
Add Comment
Please, Sign In to add comment