Advertisement
zCool

Map Navigator

May 5th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. //Warning No idea how accurate any of this is, please read the book and defer to that, lol.
  8. void WaitForEnter();
  9. string direction;
  10. int mapLocation = 0; //start in capitol
  11. string mapName[4] = {"Capitol", "District 1", "District 11", "District 12"};
  12. string mapDescription[4] = {"Where the hunger games are held every year.  It is the capitol \
  13. city of Panem.  The capitol is a wealthy urban city supported by its sourrounding impovershed \
  14. twelve districts." , "District 1 produces luxury items for the capital.  They are known for\
  15. producing 'Careers', children who are chosen to train specifically for the hunger games.", \
  16. "District 11 produces agriculture products, the girl Rue, a 12 year old tribute is from \
  17. District 11.  Rue is frail, but wily as she can manuevar easily in the trees.\
  18. Rue teams up with Katniss during the hunger games until she is killed \
  19. by District 1's Marvel.", "District 12 produces coal, Katniss Everdeen and Peeta Mallark \
  20. are the two hunger games tributes from District 12."};
  21.  
  22. cout << "Hunger Games regions" <<endl
  23.      << "0 - Capitol" << endl
  24.      << "1 - District 1" << endl
  25.      << "2 - District 11" << endl
  26.      << "3 - District 12" << endl
  27.      << "You are in the " << mapName[mapLocation] << endl
  28.      << "Please enter a direction (North, South, East, West): ";
  29.  
  30. getline(cin, direction);
  31. while(direction.compare("North")!=0 && direction.compare("South")!=0 && direction.compare("East")!=0 && direction.compare("West")!=0)
  32.  
  33. {
  34.     cout << "Please enter North, South, East or West: ";
  35.     getline(cin, direction);
  36. }
  37.  
  38.  
  39. if( direction.compare("North") == 0)
  40. {
  41.     mapLocation = mapLocation - 2;
  42.  
  43.     if( mapLocation >=0 && mapLocation < sizeof(mapName) -1  )
  44.     {
  45.        
  46.         cout << "You are in " << mapName[mapLocation] <<endl;
  47.     }  
  48.     else
  49.     {
  50.         cout << "Sorry there is nothing North of here\n";
  51.         mapLocation = mapLocation + 2;
  52.     }
  53. }
  54.  
  55. if( direction.compare("South") == 0)
  56. {
  57.     mapLocation = mapLocation + 2;
  58.    
  59.     if( mapLocation >=0 && mapLocation < sizeof(mapName) -1 )
  60.     {
  61.         cout << "You are in " << mapName[mapLocation] <<endl;
  62.     }
  63.     else
  64.     {
  65.         cout << "Sorry there is nothing South of here\n";
  66.         mapLocation = mapLocation - 2;
  67.     }
  68. }
  69.  
  70. if( direction.compare("East") == 0)
  71. {
  72.     mapLocation = mapLocation + 1;
  73.    
  74.     if( mapLocation >=0 && mapLocation < sizeof(mapName) -1 )
  75.     {
  76.         cout << "You are in " << mapName[mapLocation] <<endl;
  77.     }
  78.     else
  79.     {
  80.         cout << "Sorry there is nothing East of here\n";
  81.         mapLocation = mapLocation - 1;
  82.     }
  83. }
  84.  
  85. if( direction.compare("West") == 0)
  86. {
  87.     mapLocation = mapLocation - 1;
  88.    
  89.     if( mapLocation >=0 && mapLocation < sizeof(mapName) -1 )
  90.     {
  91.         cout << "You are in " << mapName[mapLocation] <<endl;
  92.     }
  93.     else
  94.     {
  95.         cout << "Sorry there is nothing West of here\n";
  96.         mapLocation = mapLocation + 1;
  97.     }
  98. }
  99.     cout << "Please press enter to exit...";
  100.     WaitForEnter();
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107. void WaitForEnter()
  108. {
  109.     while ( 1 ) { if ( '\n' == getchar() ) { break; } }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement