[C++]My CMD RPG

Results 1 to 12 of 12
  1. #1
    Account Upgraded | Title Enabled! I-Am-No-Fool is offline
    MemberRank
    Sep 2007 Join Date
    Location
    366Posts

    [C++]My CMD RPG

    Well, I'm a newb... here's the code. The exe link is: http://www.megaupload.com/?d=ZOPE5O24 Don't cheat when playing it by looking at the source code otherwise you're a newb too
    Spoiler:
    PHP Code:
    #include <iostream> //For basic stuff
    #include <string> //To allow cname and cviln
    #include <windows.h> //To allow Sleep and fullscreen

    using namespace std;

    int main()
    {
        
    char fscrn;

        
    cout << "Would you like to go Full Screen for the full CMD RPG Experience? y/n\n";
        
    cin >> fscrn;
        if (
    fscrn == 'y') {
        
    keybd_event(VK_MENU,0x36,0,0);
        
    keybd_event(VK_RETURN,0x1c,0,0);
        
    keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
        
    keybd_event(VK_MENU,0x36,KEYEVENTF_KEYUP,0);
        
    Sleep(200);
        
    system("CLS");
        }
        if (
    fscrn == 'n') {
            
    system("CLS");
        }
            
    string cname//Character Name
            
    string cviln//Character's Village Name
            
    string day;
            
    string month;
            
    string year;
            
    string blank;
            
    char day1;
            
    char day2;
            
    char day3;
            
    char day4;
            
    char day5;
            
    char day6;
            
    char day7;
            
    char day8;
            
    char day9;
            
    char start;

        
    cout << "Hello, And Welcome to C++ Programmer's RPG Game, to start things off could you please say what you would like your character name to be\n\n";
        
    getline(cinblank);
        
    getline(cincname);
        
    cout << "Alright Then! Now Think Of an Incredible name for your village!\n";
        
    getline(cincviln);
        
    cout << "\n" << cviln << " eh?... Nice!!\n\n";
        
    cout << "What Day Would You Like This Game To Occur On? (Please Enter a Number e.g. 9)\n";
        
    getline(cinday);
        
    cout << "\nWhat Month Would You Like This Game To occur On?\n";
        
    getline(cinmonth);
        
    cout << "\nWhat Year Would You Like This Game To occur On?\n";
        
    getline(cinyear);
        
    cout << "\n\nHere's the story... \n On The " << day << "th of " << month << ", in the year " << year << ", in the village of " << cviln << " there lived a man called " << cname << ". He was supposed to be the greatest warrior in the land, born to protect everyone from evil invading his town. Now evil has got together to defeat him... But can they...\n\nAre you ready to start? (y/n)\n";
        
    cin >> start;
        if (
    start == 'y') {
        }
        if (
    start == 'n') {
            
    cout << "I'll give you 10 Seconds...";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "10";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "9";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "8";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "7";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "6";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "5";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "4";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "3";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "2";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "1";
            
    Sleep(1000);
            
    system("CLS");
            
    cout << "0";
            
    Sleep(1000);
            
    system("CLS");
        }
        
    cout << "Day One.\nThe Evil Army Have Taken Refuge near a river a days walk away from you. Should you and your army go to attack them while they arn't expecting it? (y/n)\n";
        
    cin >> day1;
        if (
    day1 == 'y') {
            
    cout << "\nYou got to the place they had taken refuge after defeating the troops they had sent in advance to your village you had lost 3 men but you continued to their place of refuge only to be taken by suprise and slaughtered.\n\nYou will need to go back to the beginning and start your adventure again...\n";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        if (
    day1 == 'n') {
            
    cout << "\nYou waited in your hut until you heard the bells ringing to signal attack as the Evil army had sent some troops in advance. Luckily only one person was injured, and luckier, he wasn't a soldier.\n";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Day Two.\nThe Evil Forces Have Advanced Closer, Yould you like to advance on them or stand your ground? (a/s)\n";
            
    cin >> day2;
            if (
    day2 == 'a') {
                
    cout << "\nYou Advance On The Evil Army, Fighting for you might, and luckily the last remaining soldiers of the Evil Army retreat... but they'll be seen again\n";
                
    system("pause");
                
    system("CLS");
            }
            if (
    day2 == 's') {
                
    cout << "\nYou Stand Your ground and get slaughtered.. It was close but you lost.\n";
                
    system("pause");
                
    system("CLS");
                exit(
    0);
            }
        
    cout << "Day Three.\nThe Remains of the Evil Army are scattered through the mountains.. Would you like to go you and slaughter them like what they tried to do to your people? (y/n)\n";
        
    cin >> day3;
        if (
    day3 == 'y') {
            
    cout << "You and your army storm into the mountains only to find that their reinforcments had arrived and you got slaughtered\n";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        if (
    day3 == 'n') {
            
    cout << "You stay in your village and live another day\n";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Day Four.\nYou hear nothing about the Army, go out and look for them? (y/n)\n";
        
    cin >> day4;
        if (
    day4 == 'y') {
            
    cout << "A few hours after you go out to look for them, a storm starts so you go back home\n";
            
    system("pause");
            
    system("CLS");
        }
        if (
    day4 == 'n') {
            
    cout << "A few hours a storm starts so you go back to your hut\n";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Day Five.\nYou are woken up by the sound of the beels being rung - Now time for fighting. you go outside with your sword and fight with an Evil warrior, but then another evil warrior comes up to you behind you, what do you do? (j for jump away, s for spin and attack the other person\n";
        
    cin >> day5;
        if (
    day5 == 'j') {
            
    cout << "you attempt to jump away from being in a two person battle but get a sword to your leg - you are now on the floor for anyone to kill... I guess that's the end of you\n";
            
    system("pause");
            
    system("CLS");
        }
        if (
    day5 == 's') {
            
    cout << "While attacking the other Evil warrior you spin, slicing of the other one's head and you resume battle.\n";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Fighting.\nYou are stil fighting with the same warrior when you see your look out tower is falling down - and it's falling down on you, what do you do? (g for grab the warrior so that he stays where the tower will fall or r for run)";
        
    cin >> day6;
        if (
    day6 == 'g') {
            
    cout << "You grab the warrior and throw him so that he trips and is on the floor where the lookout tower is about to fall down and you run out of the way of it and ocne you're out you are satisfied by the crunch of the warrior's bones.";
            
    system("pause");
            
    system("CLS");
        }
        if (
    day6 == 'r') {
            
    cout << "You run from the falling tower, leaving the warrior behind you, and are satisfied by the fact you got out safely. While you're thinking about what it would have been like if you got crushed, you are sliced by another warrior.";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        
    cout << "Fighting again.\nAfter narrowly escaping the falling tower another warrior comes at you, this one looking very strong. What do you do? (e for engage combat or r for run)";
        
    cin >> day7;
        if (
    day7 == 'e') {
            
    cout << "You engage combat with the muscley thing only to be stomped on by a dinosaur that came out of no where";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        if (
    day7 == 'r') {
            
    cout << "You Run for your life... hey! Guess What! He's Chasing You!";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Fighting again again.\nYou're running and you're getting tired out... what do you do? (k for keep running or r for run back to your other soldiers";
        
    cin >> day8;
        if (
    day8 == 'r') {
            
    cout << "You run to your teammates and kill the ****er";
            
    system("pause");
            
    system("CLS");
        }
        if (
    day8 == 'k') {
            
    cout << "You run out of breath and get pummelled";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        
    cout << "You find a moment good to use magic, use it? (y/n)";
        
    cin >> day9;
        if (
    day9 == 'y') {
            
    cout << "Havana Cadavra!\n\nDo you really think that would work? you get pummeled";
            
    system("pause");
            
    system("CLS");
            exit(
    0);
        }
        if (
    day9 == 'n') {
            
    cout << "You're smart and don't use magic because MAGIC DOESN'T EXIST! You pwn them all.";
            
    system("pause");
            
    system("CLS");
        }
        
    cout << "Congratz, you won the awsomest CMD RPG EVER!!!!!\nWoot!\n\nYou Rock!\n\nDid you cheat?!\n\nThe Next time you click a button... this screen will close\n\nGoodbye!";
        
    system("pause");
        return 
    0;



  2. #2
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [C++]My CMD RPG

    Nice work. Looks like the code has a lot of repetitive parts. Might be handy to put those into loops.

    For example the 10 seconds waiting part:

    Code:
    for (unsigned int i = 0; i < 10; i++)
    {
        Sleep(1000);
        system("CLS");
        std::cout << i;
    }
    That might clean the code up a bit ;).

  3. #3
    Account Upgraded | Title Enabled! I-Am-No-Fool is offline
    MemberRank
    Sep 2007 Join Date
    Location
    366Posts

    Re: [C++]My CMD RPG

    Thanks, do you know a code that will make it so that you can get the CMD to roll back to where you enter something in? I need it for if they enter something that isn't one of the options I gave them. e.g.
    Code:
        cout << "Would you like to go Full Screen for the full CMD RPG Experience? y/n\n";
        cin >> fscrn;
        if (fscrn == 'y') {
        keybd_event(VK_MENU,0x36,0,0);
        keybd_event(VK_RETURN,0x1c,0,0);
        keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
        keybd_event(VK_MENU,0x36,KEYEVENTF_KEYUP,0);
        Sleep(200);
        system("CLS");
        }
        if (fscrn == 'n') {
            system("CLS");
        } else {
            cout << "Please enter a valid Letter...";
           system("pause")
    (here I need a code so that it goes back to the red up the top of the code)
        }

  4. #4
    Ragezone OG FrostElite is offline
    MemberRank
    Sep 2008 Join Date
    United StatesLocation
    1,881Posts

    Re: [C++]My CMD RPG

    Nice job for a newbie ;]

  5. #5
    Account Upgraded | Title Enabled! Mr.Lucifer is offline
    MemberRank
    Apr 2007 Join Date
    797Posts

  6. #6
    Account Upgraded | Title Enabled! I-Am-No-Fool is offline
    MemberRank
    Sep 2007 Join Date
    Location
    366Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by Mr.Lucifer View Post
    I consider that spam, it doesn't have C++ in it and you havn't made any comments about what I made and the link

  7. #7
    Browncoat Robert is offline
    Old SchoolRank
    Mar 2003 Join Date
    UKLocation
    8,658Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by I-Am-No-Fool View Post
    I consider that spam, it doesn't have C++ in it and you havn't made any comments about what I made and the link
    It's a dam good job you're not a moderator then isn't it.

    Last I checked C++ was just an addon to C, as such much of the code used in C can be easily modified to work in a C++ compiler.

  8. #8
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by I-Am-No-Fool View Post
    I consider that spam, it doesn't have C++ in it and you havn't made any comments about what I made and the link
    Get glasses maybe?
    In computer programming, a switch statement is a type of control statement that exists in most modern imperative programming languages (e.g., Pascal, C, C++, C#, and Java).
    //edit nvm rob already said that..

  9. #9
    Ragezone OG FrostElite is offline
    MemberRank
    Sep 2008 Join Date
    United StatesLocation
    1,881Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by I-Am-No-Fool View Post
    I consider that spam, it doesn't have C++ in it and you havn't made any comments about what I made and the link
    I loled at this post

  10. #10
    Valued Member Anden100 is offline
    MemberRank
    May 2008 Join Date
    124Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by Daevius View Post
    Nice work. Looks like the code has a lot of repetitive parts. Might be handy to put those into loops.

    For example the 10 seconds waiting part:

    Code:
    for (unsigned int i = 0; i < 10; i++)
    {
        Sleep(1000);
        system("CLS");
        std::cout << i;
    }
    That might clean the code up a bit ;).
    Or, as in this case, a count DOWN:

    Code:
    for (unsigned int i = 10; i > 10; i--)
    {
        Sleep(1000);
        system("CLS");
        std::cout << i;
    }
    And I-Am-No-Fool, please dont lie to your self or anyone else at this post...
    You got a crap load of unnessesary variables declared...., If you for some reason will need those variables, use an array? O.o

  11. #11
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by Anden100 View Post
    Or, as in this case, a count DOWN:

    Code:
    for (unsigned int i = 10; i > 10; i--)
    {
        Sleep(1000);
        system("CLS");
        std::cout << i;
    }
    And I-Am-No-Fool, please dont lie to your self or anyone else at this post...
    You got a crap load of unnessesary variables declared...., If you for some reason will need those variables, use an array? O.o
    I don't think that piece of code will even loop once ;-)

  12. #12
    Valued Member Anden100 is offline
    MemberRank
    May 2008 Join Date
    124Posts

    Re: [C++]My CMD RPG

    Quote Originally Posted by Daevius View Post
    I don't think that piece of code will even loop once ;-)
    sorry
    Code:
    for (unsigned int i = 10; i > 0; i--)
    {
        Sleep(1000);
        system("CLS");
        std::cout << i;
    }
    Now it will ;), or if you want a countdown of your source:
    Code:
    for (unsigned int i = 0; i < 10; i++)
    {
        Sleep(1000);
        system("CLS");
        std::cout << 10-i;
    }



Advertisement