Thread: Text based game
View Single Post
Old Nov 20th, 2005, 11:29 AM   #4
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
Here is the first part, the character creation process. It is based off the one i made when i first came here, but it has been fixed a bit so that there is now reseting, so that you can reselect your skill points if you dont like what you have. Also now you cant be stuck at 0 skill points when you reach intelligents, or agility even.. I think this part is pretty close to complete except for a few minor errors.

#include <iostream>



using namespace std;

int main()
{    

     int reset = 0;
    int Points = 20;             // These are the max points you can spend on your skills (agility, strength, and intelligents.
    int Str;                // This is your characters strength skill level.
    int Int;                 // This is your characters intelligents skill level.
    int Agi;                 // This is your characters agility skill level.
    char Name[15];             // This is your characters name.
    int Frog;
    cout << "Welcome to Monster Fighter!\nThis is a text based game based on the RPG game-type.\n\n";
    cout << "Created by: Jay[dX], www.deceptiondesigns.com\n";



/* Stats System */

  
    cout << "Press enter to continue to the character creation proccess.\n\n"; // This is the initialization of the program. It tells you whats going to happen.
    cin.get();
    system("cls");
    cout << "Name your character: "; // Character naming process.
    cin >> Name;
    cout << "Ok, so now we have your characters name.\n\n";
    cout << "Now we will continue to your character's stats. You only have 20 points, so use them wisely.\n\n"; // Point system, add skill points to your abilities with these points.
    system("cls");


/* This is the Strength skill code.*/
   do {
    do{ // This is the strength loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
    Points = 20;
    cout << "Enter your strength: "; 
    cin >> Str;
          if ( Str < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
          if ( Str > Points - 2 ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";
          }

} while ( Str > Points - 2 || Str <= 0 );
        cout << "Strength leveled up to " << Str << "!" << endl; // Lets you know that your selected integer was successfully added.
         Points = Points - Str; // Adds the selected points on to strength and reduces that same amount from your remaining skill points.
         cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the Agility skill code.*/

    do{   // This is the agility loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
          cout << "Enter your agility: ";
          cin >> Agi;
    
          if ( Agi < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
    
          if ( Agi > Points - 1 ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";

}
} while ( Agi > Points - 1 || Agi <= 0 );
        cout << "Agility leveled up to " << Agi << "!" << endl; // Lets you know that your selected integer was successfully added.
        Points = Points - Agi; // Adds the selected points on to agility and reduces that same amount from your remaining skill points.
        cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the Intelligents skill code.*/

    do{ // This is the intelligents loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
    cout << "Enter your Intelligents: "; 
    cin >> Int;
          if ( Int < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
          if ( Int > Points ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";
}
} while ( Int > Points || Int <= 0 );
        cout << "Intelligents leveled up to " << Int << "!" << endl; // Lets you know that your selected integer was successfully added.
         Points = Points - Int; // Adds the selected points on to intelligents and reduces that same amount from your remaining skill points.
         cout << "You have " << Points << " skill points remaining.\n\n";


/* This is the last segment of the code, it prints to the screen the name of your new character and your characters stats. */

   system ("cls");
   cout << "Congratulations, you have created your character successfully!\n\nHere is your character:\n\nCharacter name: " << Name << "\nAgility:-------- " << Agi << "\nStrength:------- " << Str << "\nIntelligents:--- " << Int << "\n\n\n\n\n\n\n\n\n\n";

         cout << "Enter either 1 to reselect hero skill points, or 0 to finish.";
         do {
         cin >> reset;
         
         if ( reset > 1 || reset < 0 ) {

              cout << "To reselect hero skill points enter\n1 = Yes, reselect skills.\n0 = No, they're fine.\n\n";
              }
              } while ( reset > 1 || reset < 0 );
              system ("cls");
} while ( reset == 1 );
   cin.get();
   system("PAUSE");
}
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote