Advertisement
Danicron

Game Class - TextBasedRPG

Aug 4th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.21 KB | None | 0 0
  1. #include "Game.h"
  2.  
  3.  
  4.  
  5. Game::Game()
  6. {
  7.     State = MainMenu;
  8.     Running = false;
  9. }
  10.  
  11.  
  12. Game::~Game()
  13. {
  14. }
  15.  
  16. void Game::CreateChar(std::vector<Character>& characters)
  17. {
  18.     std::string name;
  19.     std::cout << "What is your name?" << std::endl;
  20.     std::cin >> name;
  21.  
  22.     characters.emplace_back(name, 30, 25, 1);
  23. }
  24.  
  25. void Game::LoadChar()
  26. {
  27.  
  28. }
  29.  
  30. void Game::Initialise()
  31. {
  32.     int Choice = 0;
  33.     std::cout << "This world is a strange and mysterious place, there are many different kinds of people and creatures here...." << std::endl;
  34.     std::cout << "Do you have what it takes?" << std::endl;
  35.     std::cout << "Make a Choice (1 - 4)" << std::endl;
  36.     std::cout << std::endl;
  37.  
  38.     std::cout << "1. New Character" << std::endl;
  39.     std::cout << "2. Load Character" << std::endl;
  40.     std::cout << "3. Options" << std::endl;
  41.     std::cout << "4. Quit" << std::endl;
  42.  
  43.     std::cin >> Choice;
  44.     std::cout << std::endl;
  45.  
  46.     if (Choice == 1)
  47.     {
  48.         CreateChar(characters);
  49.         State = Playing;
  50.     }
  51.     else if (Choice == 4)
  52.     {
  53.        
  54.     }
  55.  
  56. }
  57.  
  58. void Game::Promptbar(std::vector<Character> characters)
  59. {
  60.     std::cout << characters[0].GetName() << " Level : " << std::to_string(characters[0].GetLevel()) << std::endl;
  61. }
  62.  
  63. void Game::PlayingMenu()
  64. {
  65.     int Choice = 0;
  66.     std::cout << "What would you like to do?" << std::endl;
  67.     std::cout << "(Type number of choice)" << std::endl;
  68.     std::cout << "1. Battle" << std::endl;
  69.     std::cout << "2. Character Screen" << std::endl;
  70.     std::cout << "3. New Character" << std::endl;
  71.     std::cout << "4. New Character" << std::endl;
  72.     std::cout << "5. New Character" << std::endl;
  73.     std::cout << "6. New Character" << std::endl;
  74.     std::cin >> Choice;
  75.     std::cout << std::endl;
  76.  
  77.     if (Choice == 2)
  78.     {
  79.         State = CharacterScreen;
  80.     }
  81. }
  82.  
  83. void Game::Gameloop(int State)
  84. {
  85.     while (Running)
  86.     {
  87.         switch (State)
  88.         {
  89.             case MainMenu:
  90.             {
  91.                 Initialise();
  92.                 break;
  93.             }
  94.             case Playing:
  95.             {
  96.                 Promptbar(characters);
  97.                 PlayingMenu();
  98.                 break;
  99.             }
  100.             case CharacterScreen:
  101.             {
  102.                 std::cout << "Skills : " << std::endl;
  103.                 std::cout << std::endl;
  104.                 for (int i = 0; i < characters[0].skills.size(); i++)
  105.                 {
  106.                     std::cout << characters[0].skills[i].GetSkillName() << std::endl;
  107.                 }
  108.                 break;
  109.             }
  110.         }
  111.     }
  112.    
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement