Advertisement
Guest User

Untitled

a guest
May 31st, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 KB | None | 0 0
  1. /*
  2. Alex Steib & Alex Jensen
  3. 5-20-2016
  4. CSP Hr 2
  5. Mr. Ferwerda
  6. Create Performance Task
  7. This program will run a short RPG in C++.
  8. */
  9.  
  10. //----------------------------------------------------------------------------
  11.  
  12. #include <iostream>
  13. #include <iomanip>
  14. #include <cstdlib>
  15.  
  16. using namespace std;
  17.  
  18. //----------------------------------------------------------------------------
  19.  
  20. // Function: titleandData
  21. // Purpose: Prints out a title screen & asks for the user for a name
  22. // Input: none
  23. // Output: the name entered by the user
  24.  
  25. void titleandData(char name[100]);
  26.  
  27. //----------------------------------------------------------------------------
  28.  
  29. // Function: prologue
  30. // Purpose: Gives the user helpful background information on the story
  31. // Input: the name entered by the user
  32. // Output: none
  33.  
  34. void prologue(char name[100]);
  35.  
  36. //----------------------------------------------------------------------------
  37.  
  38. // Function: stage1
  39. // Purpose: the first stage of the game
  40. // Inputs: the name of the user
  41. // Outputs: number of health potions & the stage number variable
  42.  
  43. void stage1(char name[], int &health, int &stageNum);
  44.  
  45. //-----------------------------------------------------------------------------
  46.  
  47. // Function: basicenemy
  48. // Purpose: the code for the basic enemies
  49. // Inputs: none
  50. // Outputs: number of health potions gained from defeating the enemy
  51.  
  52. void basicenemy(int &health);
  53.  
  54. //-----------------------------------------------------------------------------
  55.  
  56. // Function: healthNum
  57. // Purpose: the code that determines the number of health potions the player will earn from killing enemies
  58. // Inputs: the time it takes to kill the enemies
  59. // Outputs: number of health potions gained from defeating the enemy
  60.  
  61. void healthNum(double TTK, int &health);
  62.  
  63. //-----------------------------------------------------------------------------
  64.  
  65. // Function: sword1
  66. // Purpose: the code for the basic sword
  67. // Inputs: none
  68. // Outputs: the sword level
  69.  
  70. void sword1(int &swordLevel);
  71.  
  72. //-----------------------------------------------------------------------------
  73.  
  74. // Function: stage2
  75. // Purpose: the second stage of the game
  76. // Inputs: the stage number variable
  77. // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
  78. // and the stage number variable
  79.  
  80. void stage2(int &stageNum, int &health, int &speed);
  81.  
  82. //-----------------------------------------------------------------------------
  83.  
  84. // Function: enemy2
  85. // Purpose: the code for the harder enemies
  86. // Inputs: the sword level
  87. // Outputs: number of speed potions gained from defeating the enemy
  88.  
  89. void enemy2(int swordLevel, int &speed);
  90.  
  91. //-----------------------------------------------------------------------------
  92.  
  93. // Function: speedNum
  94. // Purpose: the code that determines the number of speed potions the player will earn from killing enemies
  95. // Inputs: the time to kill the enemies
  96. // Outputs: number of speed potions gained from defeating the enemy
  97.  
  98. void speedNum(double TTK, int &speed);
  99.  
  100. //-----------------------------------------------------------------------------
  101.  
  102. // Function: sword2
  103. // Purpose: the code for the better sword
  104. // Inputs: none
  105. // Outputs: the sword level
  106.  
  107. void sword2(int &swordLevel);
  108.  
  109. //-----------------------------------------------------------------------------
  110.  
  111. // Function: stage3
  112. // Purpose: the third stage of the game
  113. // Inputs: the stage number variable
  114. // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
  115. // and the stage number variable
  116.  
  117. void stage2(int &stageNum, int &health);
  118.  
  119. //-----------------------------------------------------------------------------
  120.  
  121. // Function: enemy3
  122. // Purpose: the code for the hardest enemies
  123. // Inputs: the sword level
  124. // Outputs: number of speed potions gained from defeating the enemy & number of health potions gained from defeating the enemy
  125.  
  126. void enemy2(int swordLevel, int &speed, int &health);
  127.  
  128. //-----------------------------------------------------------------------------
  129.  
  130. // Function: sword3
  131. // Purpose: the code for the best sword
  132. // Inputs: none
  133. // Outputs: the sword level
  134.  
  135. void sword3(int &swordLevel);
  136.  
  137. //-----------------------------------------------------------------------------
  138.  
  139. // Function: finale
  140. // Purpose: the final stage of the game
  141. // Inputs: the stage number variable
  142. // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
  143. // and the stage number variable
  144.  
  145. void finale(int &stageNum, int &health, int &speed);
  146.  
  147. //-----------------------------------------------------------------------------
  148. // Functions: dragon
  149. // Purpose: the code for the dragon boss
  150. // Inputs: the sword level
  151. // Outputs: the stage number variable
  152.  
  153. void enemy2(int swordLevel, int &stageNum);
  154.  
  155. //-----------------------------------------------------------------------------
  156. // Function: epilogue
  157. // Purpose: the code for the epilogue
  158. // Inputs: the stage number variable
  159. // Outputs: none
  160.  
  161. void epilogue(int stageNum);
  162.  
  163. //-----------------------------------------------------------------------------
  164.  
  165. //Function : Tutorial
  166. //Purpose basic tutorial of attack and health potions
  167. //Input : none
  168. //Output : none
  169.  
  170. void tutorial();
  171.  
  172. //-----------------------------------------------------------------------------
  173.  
  174. //Function : First dungeon
  175. // Purpose : create first dungeon
  176. //Input : none
  177. // Output : none
  178.  
  179. void firstdungeon (char name[]);
  180.  
  181. //-----------------------------------------------------------------------------
  182.  
  183. void main()
  184. {
  185. char name[100];
  186.  
  187. titleandData(name);
  188. prologue(name);
  189.  
  190. }
  191.  
  192. //-----------------------------------------------------------------------------
  193.  
  194. void titleandData(char name[])
  195. {
  196. srand(time(0));
  197. cout << "Welcome to INSERT RPG NAME HERE" << endl;
  198. cout << endl;
  199. cout << "Please enter your character’s name: ";
  200. cin >> name[24];
  201. }
  202.  
  203. //-----------------------------------------------------------------------------
  204.  
  205. void prologue(char name[])
  206. {
  207.  
  208. cout << "Once upon a time, there once was a brave hero named " << name[24] << endl;
  209. cout << "Our hero was having a normal day until an evil dragon decided to destroy our hero’s home village. Now, " << name[24] << " must save the village from the terrors of the dragon. " << endl;
  210. system("pause");
  211. cout << " ___====-_ _-====___" << endl;
  212. cout << " __--^^^ // \\ ^^^--_" << endl;
  213. cout << " _-^ // ( ) \\ ^-_" << endl;
  214. cout << " - // |\^^/| \\ -" << endl;
  215. cout << " _/ // (0::0) \\ \_" << endl;
  216. cout << " / (( \\// )) \ " << endl;
  217. cout << " - \\ (oo) // -" << endl;
  218. cout << " - \\ / \/ \ // -" << endl;
  219. cout << " - \\/ \// -" << endl;
  220. cout << "/ /| /\ ( ) /\ |\ \ " << endl;
  221. cout << "|/ | /\_/\_/\_/ \_/\ ( /\ ) /\_/ \_/\_/\_/\ | \|" << endl;
  222. }
  223.  
  224. //-----------------------------------------------------------------------------
  225.  
  226. void tutorial()
  227. {
  228. //basicenemy();
  229. //healthpotion();
  230. }
  231.  
  232. //-----------------------------------------------------------------------------
  233.  
  234. void firstdungeon (char name[])
  235. {
  236. int chance;
  237. int x;
  238.  
  239. //Tutorial for enemies and health
  240.  
  241.  
  242. for (x = 0; x < 15; x ++)
  243. {
  244.  
  245. chance = (rand() % 3) + x;
  246. if (chance < 5)
  247. cout << "The path is clear" << endl;
  248. else if (chance < 8 && chance > 5)
  249. cout << "A health potion has appeared" << endl;
  250. //Healthpotion()
  251. else if (chance < 13)
  252. //basicenemy()
  253. cout << " A foe stands in your way" << endl;
  254. //Combat()
  255.  
  256. if (x > 10)
  257. chance = (rand() % 5) + 4;
  258. if (chance < 5)
  259. cout << "The path is clear" << endl;
  260. else if (chance < 8 && chance > 5)
  261. cout << "A health potion has appeared" << endl;
  262. else if (chance < 13)
  263. //basicenemy()+
  264.  
  265. cout << " A foe stands in your way" << endl;
  266. //Combat()
  267.  
  268. }
  269.  
  270. cout << "You have found the final enemy" << endl;
  271. system("pause");
  272. cout << " THE MIGHTY DRAGON!!! "<< endl;
  273. //Dragon()
  274. cout << " ___====-_ _-====___" << endl;
  275. cout << " __--^^^ // \\ ^^^--_" << endl;
  276. cout << " _-^ // ( ) \\ ^-_" << endl;
  277. cout << " - // |\^^/| \\ -" << endl;
  278. cout << " _/ // (0::0) \\ \_" << endl;
  279. cout << " / (( \\// )) \ " << endl;
  280. cout << " - \\ (oo) // -" << endl;
  281. cout << " - \\ / \/ \ // -" << endl;
  282. cout << " - \\/ \// -" << endl;
  283. cout << "/ /| /\ ( ) /\ |\ \ " << endl;
  284. cout << "|/ | /\_/\_/\_/ \_/\ ( /\ ) /\_/ \_/\_/\_/\ | \|" << endl;
  285. }
  286.  
  287. void basicenemy(int &health)
  288. {
  289. // Variable Declarations
  290. int basichealth = 3; // health for the enemy
  291. int basicdamage = 2; // damage for the enemy
  292. int clock = 0; // "shot clock"
  293. int attack = 0; // used for attacks
  294. int counterattack = 0; // used for counterattacks
  295. int stage = 1; // stage number
  296. int hpots; // number of health potions
  297.  
  298. for (int rounds = 0; rounds < 5; rounds++)
  299. {
  300. system("CLS");
  301. cout << "Here comes an enemy!" << endl;
  302. clock++;
  303. cout << "Enter 1 to attack!" << endl;
  304. cin >> attack;
  305. if ((attack == 1) && (clock <= 5))
  306. {
  307. basichealth = basichealth - 2;
  308. cout << "Direct hit! -2 health" << endl;
  309. if (basichealth < 0)
  310. {
  311. cout << "Your enemy is dead!" << endl;
  312. stage = stage + 1;
  313. hpots = rand() * 5;
  314. if (stage == 2)
  315. {
  316. stage2(stage, hpots);
  317. }
  318. }
  319. counterattack = rand() * 10;
  320.  
  321. if (counterattack < 6)
  322. {
  323. health = health - 2;
  324. cout << "Your enemy counter-attacked you! -2 health" << endl;
  325. if (health < 0)
  326. {
  327. cout << "You're dead!" << endl;
  328. }
  329. }
  330.  
  331. attack = 0;
  332. clock = 0;
  333.  
  334. }
  335. if (clock > 5)
  336. {
  337. counterattack = rand() * 10;
  338.  
  339. if (counterattack < 6)
  340. {
  341. health = health - 2;
  342. }
  343.  
  344. clock = 0;
  345. }
  346. }
  347. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement