it's not much of a game, but...

• 11-18-2002
blasta
it's not much of a game, but...
here is my very first game. it's a math game, and doesent even use graphics (i dont know how to put them in yet) but just asks you a series of questions and says something (different each time) and ends. it says some pretty stupid things, but im just happy it worked. dont bother with it if you're offended by 'dumbum!' im not sure if this is how you're supposed to post games, so tell me if im supposed to attach a file or something instead.

Code:

```#include <iostream> #include <stdlib.h> using namespace std; int main() {         int answer1;  //variable1         cout<<"What is 2+2?";  //Ya betta know that one!         cin>>answer1;  //here's where the value goes into our trusty variable, answer1         if(answer1==4)  //if the user puts in 4, it will be correct         {     cout<<"You are right. 2+2=4. Very good! You are very smart! Now onto the next question!";         int answer2;  //variable2         cout<<"What is 4+4?";  //a little bit harder         cin>>answer2;  //here's where the value goes into our trusty variable, answer2         if(answer2==8)  //if the user puts in 8, it will be correct         {         cout<<"Correct again! You must be mega smart!";         int answer3;  //variable3         cout<<"What is 8+8?";  //now we're gettin to the real hard parts ;)           cin>>answer3;  //here's where the value goes into our trusty variable, answer3         if(answer3==16)  //if the user puts in 16, it will be correct         {         cout<<"You're right again! Awesome! Now it's time for multiplication!";         int answer4;  //variable 4         cout<<"What is 5x5?";         cin>>answer4;  //here's where the value goes into our trusty variable, answer4         if(answer4==25)  //if the user puts in 25, it will be correct         {         cout<<"You truly are amazing.";         int answer5;  //variable 5         cout<<"What is 10x10?";         cin>>answer5;  //here's where the value goes into our trusty variable, answer5         if(answer5==100)  //if the user puts in 100, it will be correct         {         cout<<"Ultimate. You have passed all the tests I have given you. Now it is time to pass the hardest one of all.";         int answer6;  //variable 6         cout<<"What is 1000x1000?";         cin>>answer6;  //here's where the value goes into our trusty variable, answer6         if(answer6==1000000)  //if the user puts in 1000000, it will be correct         {         cout<<"AWESOME!!!!!!!!!!!!!! You win!!!! NOT!!!!! Here is the final question.";         int answer7;  //variable 7         cout<<"What is 5+5-2+301-29x50?";         cin>>answer7;  //here's where the value goes into our trusty variable, answer7         if(answer7==14000)         {         cout<<"You are very right. You have really won this time!";         }         else         {         cout<<"You are very wrong. You really haven't won this time!";         }         }         else         {         cout<<"Hahaha, I knew you'd lose at the ultimate question. Hahaha!";         }         }         else         {         cout<<"You got pretty far, but now you die!";         }         }         else         {         cout<<"You lose. Goodbye.";         }         }         else         {         cout<<"Wrong! Goodbye!";         }         }         else         {         cout<<"Wrong on the second question, what a shame...";  //You lose!         }         }     else         {     cout<<"You are wrong you stupid dumbum. Get outta here!";  //This happens if the answer is anything but 2         }     system("PAUSE");     return 0;     }```
stick it in your compiler and enjoy! :D

Code tags amended by Hammer
• 11-18-2002
Hunter2
Hmm, it looks nice. But to make the code more readable, you might want to create a bool variable that keeps whether or not the last question was right. Like this:
Code:

```int response; bool rightSoFar = true; cout << "What is 2+2?\n"; cin >> response; if(response == 4)   cout << "Right!\n"; else {   cout << "Wrong, dumbo!";   rightSoFar = false; } if(rightSoFar) {   cout << (next question);   cin >> response;   if(response is right)       cout << "Right!\n";   else   {       cout << "Wrong!\n";       rightSoFar = false;   } } if(rightSoFar) {   //same as last one }```
and so on. It just helps to make the code more readable; the way it is, it's really hard to find out what response goes with what question, since the response to the first question is several pages down :)

P.S. Actually, yes you're supposed to attach a file :) Most people don't want to bother compiling code.
• 11-19-2002
blasta
i guess most people are different from me then, because i usually dont want to download :p

P.S. i meant to fix the code tags for the first post, but for some reason it said that the post didnt exist when i tried to edit it. it was weird...
• 11-19-2002
fry
I'd rather download an exe and source than have to cut, copy, paste, compile and run myself :) Too much effort :p

Plus there is no surprise as to what the program does anymore ;) hehe
• 11-20-2002
blasta
well you COULD close your eyes!:p
• 11-20-2002
fry
Lol, i tried that, but i couldn't see what i was doing :D
• 11-21-2002
blasta
ah, good point!:)