Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int input = -1, location = 0;
- do
- {
- if (
- (
- (input != -1 && input != 2 && input != 4 && input != 6 && input != 8) ||
- (input == 2 && ((location & 2) == 2)) ||
- (input == 4 && ((location & 1) == 0)) ||
- (input == 6 && ((location & 1) == 1)) ||
- (input == 8 && ((location & 2) == 0))
- ) ? 0 * printf("Cannot move in this direction from this room.\r\n")
- : 1 + ((input == -1) ? 0 * printf("== Super Text Adventure ==\r\n") : 0)
- + 0 * (
- location = (input == 8) ? (location & 1) :
- ((input == 2) ? (location | 2) :
- ((input == 4) ? (location & 2) :
- ((input == 6) ? (location | 1) : location)))
- )
- )
- printf("---------\r\n| %c | %c |\r\n---------\r\n| %c | %c |\r\n---------\r\nYou are in room %d.\r\n%s\r\n",
- location == 0 ? 'X':' ',
- location == 1 ? 'X':' ',
- location == 2 ? 'X':' ',
- location == 3 ? 'X':'T',
- location + 1,
- location == 3 ? "You have found the treasure! You win!\r\n" :
- "Which direction would you like to move?\r\n[8] North\r\n[4] "
- "West\r\n[2] South\r\n[6] East\r\n[0] Exit\r\n<===========>");
- } while ((location == 3 ? 0 : (1 + 0 * scanf("%u", &input))) && input != 0);
- }
Add Comment
Please, Sign In to add comment