C++ Terminal Game


SUBMITTED BY: Guest

DATE: Jan. 24, 2014, 7:07 p.m.

FORMAT: C++

SIZE: 2.6 kB

HITS: 1242

  1. //technical stuff
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <sstream>
  5. #include <conio.h>
  6. #include <stdio.h>
  7. #include <ctype.h>
  8. using namespace std;
  9. string entry(){
  10. string input = "";
  11. char ch = getch();
  12. while (ch != '\r'){
  13. if (ch == '.'){
  14. cout<<ch;
  15. ch=getch();
  16. }
  17. else if (ch == '\b'){
  18. cout<<'\b';
  19. input.resize((input.length()-1));
  20. }
  21. else {
  22. ch = tolower(ch);
  23. input += ch;
  24. cout<<ch;
  25. ch = getch();
  26. }
  27. }
  28. cout << "\n"+input;
  29. string letsee = input;
  30. return letsee;
  31. }
  32. void actual(){
  33. //prints welcome message to console
  34. cout << "Welcome to this annoying game C & D like to play on long car trips!\n";
  35. //infinite loop (this game goes on forever. Literally.
  36. while (1<2){
  37. //first question
  38. cout << "\n\nGuess what? ";
  39. //creates all variables (inputs and answers and all that jazz)
  40. string a1, a2, a3, c2, c3, pc2, pc3, complaint;
  41. string bollucks[]={"you die","You die.","chicken pie","Chicken pie.","cow pie","Cow pie.","mud pie","Mud pie."};
  42. a1=entry(); //make it so that it's lower-case
  43. if (a1 == "chicken butt"){
  44. cout << "\nGuess who? ";
  45. int temp = rand() % 2;
  46. if (temp == 1){
  47. c2 = "chicken poo";
  48. pc2 = "Chicken poo.";
  49. }
  50. else{
  51. c2 = "it's you";
  52. pc2 = "It's you.";
  53. }
  54. a2=entry();
  55. if (a2==c2){
  56. cout << "\nGuess why? ";
  57. a3= entry();
  58. int temp2 = rand() % 4;
  59. c3= bollucks[temp2];
  60. pc3= bollucks[(temp2+1)];
  61. if (a3==c3){
  62. cout<<"\nRight.";
  63. }
  64. else {
  65. cout<<"\nWrong. "+pc3;
  66. cout<<"\nEnter your complaint: ";
  67. complaint = entry();
  68. }
  69. }
  70. else{
  71. cout << "\nWrong. "+pc2;
  72. }
  73. }
  74. else{
  75. cout<< "\nWrong. Chicken butt.";
  76. }
  77. }
  78. }
  79. //main function
  80. int main(){
  81. actual();
  82. return 0;
  83. }

comments powered by Disqus