Advertisement
pazryx

Room Game Code v001

May 5th, 2016
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. string command, target;
  9. bool key_have, door_open, key_know;
  10. int dirt_in_pocket;
  11.  
  12. void inspect()
  13. {
  14. switch(target)
  15. {
  16. case 'door':
  17.  
  18. case 'room':
  19.  
  20. case 'floor':
  21.  
  22. case 'walls':
  23.  
  24. case 'ceiling':
  25.  
  26. case 'key':
  27.  
  28. case 'computer':
  29.  
  30. default:
  31. system("CLS");
  32. cout << "Invalid input.\n\n";
  33. END = '';
  34. }
  35. }
  36.  
  37. void take()
  38. {
  39. switch(target)
  40. {
  41. case 'door':
  42.  
  43. case 'room':
  44.  
  45. case 'floor':
  46.  
  47. case 'walls':
  48.  
  49. case 'ceiling':
  50.  
  51. case 'key':
  52.  
  53. case 'computer':
  54.  
  55. default:
  56. system("CLS");
  57. cout << "Invalid input.\n\n";
  58. END = '';
  59. }
  60. }
  61.  
  62. void use()
  63. {
  64. switch(target)
  65. {
  66. case 'door':
  67.  
  68. case 'room':
  69.  
  70. case 'floor':
  71.  
  72. case 'walls':
  73.  
  74. case 'ceiling':
  75.  
  76. case 'key':
  77.  
  78. case 'computer':
  79.  
  80. default:
  81. system("CLS");
  82. cout << "Invalid input.\n\n";
  83. END = '';
  84. }
  85. }
  86.  
  87. void help()
  88. {
  89. switch(target)
  90. {
  91. case 'inspect':
  92. cout << "You can use this to look around.\n\n";
  93. break;
  94. case 'take':
  95. cout << "This lets you take things.\n\n";
  96. break;
  97. case 'use':
  98. cout << "Allows you to use something in your posession.\n\n";
  99. break;
  100. case 'reset':
  101. cout << "This will reset all variables and let you start over.\n\n";
  102. break;
  103. case 'end':
  104. cout << "The game ends and then closes.\n\n";
  105. break;
  106. case 'help':
  107. cout << "Do you really need to know what this does...\n\n";
  108. break;
  109. case '':
  110. cout << "Type '/help <target>' to find out more about it:";
  111. cout << "1. inspect\n2. take\n3. use\n4. reset\n5. end\n6. help\n7. ' '\n\n";
  112. break;
  113. default:
  114. system("CLS");
  115. cout << "Invalid input.\n\n";
  116. END = '';
  117. }
  118. }
  119.  
  120. void reset()
  121. {
  122. char RESET;
  123.  
  124. while(RESET == '')
  125. {
  126. system("CLS");
  127. cout << "Are you sure you want to reset everything? [Y or N]\n\n";
  128. cin << RESET;
  129.  
  130. if(RESET == 'y' || RESET == 'Y')
  131. {
  132. system("CLS");
  133. key_have = false;
  134. door_open = false;
  135. key_know = false;
  136. dirt_in_pocket = 0;
  137. cout << "All variables have been reset. Enter a new command.\n\n";
  138. }
  139. else if(RESET == 'n' || RESET == 'N')
  140. {
  141. system("CLS");
  142. }
  143. else
  144. {
  145. system("CLS");
  146. cout << "Invalid input.\n\n";
  147. RESET = '';
  148. }
  149. }
  150. }
  151.  
  152. void end()
  153. {
  154. char END;
  155.  
  156. while(END == '')
  157. {
  158. system("CLS");
  159. cout << "Are you sure you want to exit? [Y or N]\n\n";
  160. cin << END;
  161.  
  162. if(END == 'y' || END == 'Y')
  163. {
  164. system("CLS");
  165. cout << "Thank you for playing, have a nice day!";
  166. system('pause');
  167. return 0;
  168. }
  169. else if)(END == 'n' || END == 'N')
  170. {
  171. system("CLS");
  172. }
  173. else
  174. {
  175. system("CLS");
  176. cout << "Invalid input.\n\n";
  177. END = '';
  178. }
  179. }
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement