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

This is a discussion on it's not much of a game, but... within the Game Programming forums, part of the General Programming Boards category; here is my very first game. it's a math game, and doesent even use graphics (i dont know how to ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    20

    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!


    Code tags amended by Hammer

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    20
    i guess most people are different from me then, because i usually dont want to download

    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...
    Last edited by blasta; 11-19-2002 at 07:16 PM.

  4. #4
    fry
    fry is offline
    Registered User fry's Avatar
    Join Date
    Mar 2002
    Posts
    128
    I'd rather download an exe and source than have to cut, copy, paste, compile and run myself Too much effort

    Plus there is no surprise as to what the program does anymore hehe
    IDE: Dev C++ 5
    Lib: Allegro
    OS: Windows 2000

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    20

    Talking

    well you COULD close your eyes!

  6. #6
    fry
    fry is offline
    Registered User fry's Avatar
    Join Date
    Mar 2002
    Posts
    128
    Lol, i tried that, but i couldn't see what i was doing
    IDE: Dev C++ 5
    Lib: Allegro
    OS: Windows 2000

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    20
    ah, good point!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 11:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-25-2002, 12:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21