Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <string>
  5. #include <cstdlib>
  6. #include <ctime>
  7. using namespace std;
  8.  
  9. void splashScreen();
  10. void login();
  11. void command();
  12. void startzone();
  13. void starterSwamp();
  14. void lockedShack();
  15. void turnBack();
  16. void encounter();
  17. void movement();
  18. char userCommand[30];
  19. int x, y;
  20.  
  21. int main()
  22. {
  23.     ifstream inputData;
  24.     inputData.open("data.txt");
  25.     splashScreen();
  26.     login();
  27.     do{
  28.     //sets player grid to 0,0 until proper login system is working
  29.     x = 0; y = 0;
  30.     command();
  31.     //checks for movement each command
  32.     movement();
  33.     //Startzone (0, 0)
  34.     if(x == 0 && y == 0)
  35.         startzone();
  36.     //Encounter in cave(0, 1)
  37.     else if(x == 0 && y == 1)
  38.         encounter();
  39.     else if(x == 0 && y == -1)
  40.         starterSwamp();
  41.     else if(x == 1 && y == 0)
  42.         turnBack();
  43.     else if(x == -1 && y == 0)
  44.         lockedShack();
  45.     }while(!_stricmp(userCommand, "quit"));
  46.    
  47.     return 0;
  48. }
  49.  
  50. void splashScreen()
  51. {
  52.     cout << "================================================" << endl;
  53.     cout << "==       ________                             ==" << endl;
  54.     cout << "==      | o __ o |        Title               ==" << endl;
  55.     cout << "==       \\_ __ _/                             ==" << endl;
  56.     cout << "==      __ |  | __                            ==" << endl;
  57.     cout << "==    **************                          ==" << endl;
  58.     cout << "================================================" << endl;
  59. }
  60. void login()
  61. {
  62.     string userName, userPass;
  63.     cout << "Username: ";
  64.     cin >> userName;
  65.     cout << "Password: ";
  66.     cin >> userPass;
  67.     //check userName to username in file
  68.     //check userPass to password in file
  69. }
  70. void command()
  71. {
  72.     cout << ">> ";
  73.     cin >> userCommand;
  74. }
  75. void startzone()
  76. {
  77.     cout << "You are in the center of a foggy forest. There is a marshy \n"
  78.         << "swamp to the South.  To the East lies a thick line of bushes.\n"
  79.         << "To the North through a winding path you catch a glimpse of a\n"
  80.         << "cave with a shinng light coming out. To the West is a small\n"
  81.         << "wooden shack, with a locked door. " << endl;
  82. }
  83. void starterSwamp()
  84. {
  85.     cout << "You have ventured into the dangerous marshes. To the North lies \n"
  86.         << "a forest clearing. To the east lies a beached row boat. To the \n"
  87.         << "south the water gets deeper, out into a large lake. To the \n"
  88.         << "west is a rock formation, but its hard to make out from here." << endl;
  89. }
  90. void lockedShack()
  91. {
  92.     cout << "You approach the shack, only to find that there is a pad lock \n"
  93.         << "on the door. Perhaps if you had the key?" << endl;
  94. }
  95. void turnBack()
  96. {
  97.     cout << "This area is impassible. You have been forced to turn back. " << endl;
  98. }
  99. void movement()
  100. {
  101.     if(_stricmp(userCommand, "walk north") == 1)
  102.     {
  103.         //moves character 1 place up grid
  104.         x = x;
  105.         y = y + 1;
  106.     }
  107.     else if(_stricmp(userCommand, "walk south") == 1)
  108.     {
  109.         //moves character 1 place down grid
  110.         x = x;
  111.         y = y - 1;
  112.     }
  113.     else if(_stricmp(userCommand, "walk east") == 1)
  114.     {
  115.         //moves character 1 place right of grid
  116.         x = x + 1;
  117.         y = y;
  118.     }
  119.     else if(_stricmp(userCommand, "walk west") == 1)
  120.     {
  121.         //moves character 1 place left of grid
  122.         x = x - 1;
  123.         y = y;
  124.     }
  125. }
  126. void encounter()
  127. {
  128.     srand(time(0));
  129.     int num = rand() % 10 + 1;
  130.     switch(num)
  131.     {
  132.     case 1:
  133.     case 2:
  134.     case 3:
  135.     case 4:
  136.     case 5:
  137.     case 6:
  138.     case 7:
  139.     case 8:
  140.     case 9:
  141.     case 10:
  142.         cout << "STOMP! A giant stone golem almost flattened you, luckily you halted an \n"
  143.             << "inch short of his foot as it fell. He begins to raise his leg again \n"
  144.             << "for another bash." << endl;
  145.         command();
  146.     }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement