Advertisement
Guest User

C++ adventureGame

a guest
Nov 14th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <windows.h>
  4. class explore
  5. {
  6. private:
  7.     bool isExploring = true;
  8.     bool isInCombat = false;
  9.     int playerLocationX=0;
  10.     int playerLocationY=0;
  11.     int encounterEnemy = 0;
  12.  
  13. public:
  14.     bool InitializeBattle()
  15.     {
  16.         if (encounterEnemy == 1)
  17.         {
  18.             isInCombat = true;
  19.             return isInCombat;
  20.         }
  21.         else
  22.         {
  23.             isInCombat = false;
  24.             return isInCombat;
  25.         }
  26.        
  27.     }
  28.     bool ExploreMode()
  29.     {
  30.         if (encounterEnemy == 0)
  31.         {
  32.             isExploring = true;
  33.         }
  34.         else{ isExploring = false; }
  35.         return isExploring;
  36.     }
  37.     int RunExploring()
  38.     {
  39.         std::string exploreInput = "";
  40.         std::cin >> exploreInput;
  41.         if (exploreInput == "N")
  42.         {
  43.             GoNorth();
  44.         }
  45.         if (exploreInput == "E")
  46.         {
  47.             GoEast();
  48.         }
  49.         if (exploreInput == "W")
  50.         {
  51.             GoWest();
  52.         }
  53.         if (exploreInput == "S")
  54.         {
  55.             GoSouth();
  56.         }
  57.         return 0;
  58.     }
  59.     int GoNorth()
  60.     {
  61.  
  62.         playerLocationY += 1;
  63.         return playerLocationY;
  64.     }
  65.     int GoEast()
  66.     {
  67.         playerLocationX += 1;
  68.         return playerLocationX;
  69.     }
  70.     int GoWest()
  71.     {
  72.         playerLocationX -= 1;
  73.         return playerLocationX;
  74.     }
  75.     int GoSouth()
  76.     {
  77.         playerLocationY -=1;
  78.         return playerLocationY;
  79.     }
  80.     int ShowPlayerLocation
  81.         ()
  82.     {
  83.         std::cout << playerLocationX<<playerLocationY<<std::endl;
  84.         return 0;
  85.     }
  86. };
  87. class player
  88. {
  89. private:
  90.     int playerIntelligence;
  91.     int playerStrength;
  92.     int playerAgility;
  93.     int playerDamage;
  94.     int playerGold;
  95.     int playerHealth;
  96. public:
  97.     player()
  98.     {}
  99.     int setPlayer()
  100.     {
  101.         playerIntelligence = 10;
  102.         playerStrength = 10;
  103.         playerAgility = 10;
  104.         playerDamage = 10;
  105.         playerGold = 100;
  106.         playerHealth = 10;
  107.         return playerHealth;
  108.         return playerIntelligence;
  109.         return playerStrength;
  110.         return playerAgility;
  111.         return playerDamage;
  112.         return playerGold;
  113.     }
  114.     int getPlayer()
  115.     {
  116.         std::cout << "Your have " << playerGold << "gold coins " << std::endl;
  117.         std::cout << "====================================================" << std::endl;
  118.         std::cout << "======\nStats\n======\n" << " Your Intelligence is " << playerIntelligence << std::endl;
  119.         std::cout << "====================================================" << std::endl;
  120.         std::cout << "Your Strength is " << playerStrength << std::endl;
  121.         std::cout << "====================================================" << std::endl;
  122.         std::cout << "Your Agility is " << playerAgility << std::endl;
  123.         std::cout << "====================================================" << std::endl;
  124.         std::cout << "Your totall Damage is " << playerDamage << std::endl;
  125.         std::cout << "====================================================" << std::endl;
  126.         std::cout << "Your Health is " << playerHealth << std::endl;
  127.         return 0;
  128.     }
  129.     int playerTakeDamage(int p_ienemyDamage, int p_ienemyHitrate)
  130.     {
  131.  
  132.         playerHealth -= p_ienemyDamage;      //<---- Leder ej till att man tar skada
  133.         return playerHealth;
  134.     }
  135.  
  136. };
  137. class BattleScene
  138. {
  139.  
  140. private:
  141.     bool enemyIsDead;
  142.     int enemyDamage = 0;
  143.     int enemyHp = 0;
  144.     int enemyAttackTime;
  145.     int enemyGold;
  146.     int playerdamage = 0;
  147.     int playerhp;
  148.     int playerAttackTime;
  149.     std::string playerCommand;
  150.     std::string enemyName;
  151.  
  152.  
  153.  
  154. public:
  155.     BattleScene()                                                                                       //Konstruktor körs vid kall på medtoden
  156.     {
  157.        
  158.     }
  159.  
  160.     int fireball()
  161.     {
  162.     }
  163.     int BattleStart(std::string p_senemyname, int p_ienemydamage, int p_ienemyHealth, int p_igold)     //initierar variabler i start av fight
  164.     {
  165.         enemyIsDead = false;
  166.         enemyName = p_senemyname;
  167.         enemyDamage = p_ienemydamage;
  168.         enemyHp = p_ienemyHealth;
  169.         enemyGold = p_igold;
  170.         std::cout << "A Battle has begun the enemy is a " << enemyName;
  171.         return 0;
  172.     }
  173.     int playerTurn(int p_iplayerdamage, int p_ienemyhealth)                                              //spelarens tur
  174.     {
  175.  
  176.  
  177.         std::string enemyCondition;                    
  178.         std::cout << "The Battle Keeps Going"<<std::endl;//ska göra enemycondition till egen metod.
  179.         playerCommand = "";
  180.         enemyCondition = "stands before you";
  181.         if (enemyHp <= 15 && enemyHp>0)
  182.         {
  183.             enemyCondition = "is nearly Dead";
  184.         }
  185.         if (enemyHp <= 30 && enemyHp >= 15)
  186.         {
  187.             enemyCondition = "is bleeding ";
  188.         }
  189.         if (enemyHp <= 0)
  190.         {
  191.             enemyCondition = "is Dead";
  192.         }
  193.  
  194.  
  195.         std::cout << "Enemy " << enemyName << std::endl;
  196.         std::cout << "Enemy Health " << enemyHp << std::endl;
  197.         std::cout << "The fearsome " << enemyName << enemyCondition << std::endl << " Choose your action either [A]ttack or [P]laceholder or [C}heckstats" << std::endl;
  198.  
  199.         std::cin >> playerCommand;
  200.         if (playerCommand == "A")
  201.         {
  202.             Beep(400, 500);
  203.             std::cout << "You attack the " << enemyName << " and it loses " << p_iplayerdamage << " Hp \n " << std::endl;
  204.             enemyHp -= p_iplayerdamage;
  205.         }
  206.         else if (playerCommand == "P")
  207.         {
  208.             std::cout << "PlaceHolder" << std::endl;
  209.         }
  210.         else if (playerCommand == "C")
  211.         {
  212.             player playerCall;                                                                              //gör inget för tillfället
  213.             playerCall.getPlayer();                                                                         //gör inget för tillfället
  214.  
  215.  
  216.         }
  217.  
  218.         else
  219.         {
  220.             std::cout << "You skip your turn because of ignorace" << std::endl;
  221.         }
  222.  
  223.         playerCommand = "";
  224.         return enemyHp;
  225.     }
  226.  
  227.     void DeathChecker()
  228.     {
  229.         if (enemyHp <= 0)
  230.         {
  231.             std::cout << "The Enemy is Dead";
  232.             WinBattle();
  233.         }
  234.     }
  235.     int WinBattle()      //winbattle metod
  236.     {
  237.         std::cout << std::string(20, '\n');
  238.         std::cout << " Win Battle PlaceHolder for epic loot";
  239.  
  240.         VictoryMusic();    //kallar på funky ljud
  241.         return 0;
  242.     }
  243.  
  244.     int enemyTurn(int p_ienemyDamage)                       //fiendens tur
  245.     {
  246.         player playerCall;
  247.         std::cout << "THE ENEMY ATTACKS" << std::endl;
  248.         Beep(1300, 200);
  249.  
  250.         playerCall.playerTakeDamage(enemyDamage, 100);                    //<---- Leder ej till att man tar skada
  251.         return 0;
  252.     }
  253.     void VictoryMusic()                 //spelar funky ljud
  254.     {
  255.         Beep(400, 500);
  256.         Beep(500, 400);
  257.         Beep(600, 300);
  258.         Beep(700, 200);
  259.         Beep(800, 550);
  260.         Beep(900, 600);
  261.         Beep(1000, 800);
  262.         Beep(1300, 200);
  263.     }
  264.  
  265.  
  266.  
  267. };
  268.  
  269.  
  270.  
  271.  
  272. int main(int argc, char*argv[])
  273. {
  274.  
  275.     player playerInitialize;
  276.     BattleScene btc;
  277.     explore objExplore;
  278.     objExplore.ShowPlayerLocation();
  279.     if (objExplore.ExploreMode() == true)
  280.     {
  281.         while (objExplore.ExploreMode()== true)
  282.         {
  283.             objExplore.ShowPlayerLocation();
  284.             objExplore.RunExploring();
  285.         }
  286.        
  287.     }
  288.     if (objExplore.InitializeBattle())
  289.     {
  290.  
  291.         playerInitialize.setPlayer();                           //object av battlescene
  292.         btc.BattleStart("Minotaur ", 50, 50, 200);   //Initierar fight med en fiende
  293.         for (int i = 0; i < 10000; i++)
  294.         {
  295.  
  296.  
  297.             btc.playerTurn(5, 50);   //playerturn behöver fixa proper parameters
  298.             btc.enemyTurn(10);         //enemyTurn
  299.             btc.DeathChecker();     //kollar ifall fienden är död
  300.  
  301.             if (i = 10000)
  302.             {
  303.                 i = 0;
  304.             }
  305.         }
  306.     }
  307. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement