| jayme |
Nov 13th, 2005 3:49 PM |
Character creation tutorial
I am a begginer, and just thought that i could put some of the tutorials you would find on forums, into a working code that could actually be useful to some of you later on in your programming career. This tutorial is for begginers, please criticize me, comment, and anything else you feel.. just remember this is my first program other than hello world pretty much so i am really proud of myself, also proud of how long it is, even though that might not be important :D
:
/* Character creation tutorial for begginers. Any questions, concerns or comments
can be e-mailed to iced_out_jay@hotmail.com. Include credits if you use this tutorial
on your website. Created by: Jayme Schroeder.*/
#include <stdio.h>
#include <windows.h>
#include <string>
#include <iostream.h>
using namespace std;
int main()
{
int Points = 20; // These are the max points you can spend on your skills (agility, strength, and intelligents.
int Str = -1; // This is your characters strength skill level.
int Int = 0; // This is your characters intelligents skill level.
int Agi = 0; // This is your characters agility skill level.
char Name[500]; // This is your characters name.
cout << "this is a test created by Jay to see if he has even" << endl << "learned anything since he started c++ programming.. ok so here it goes.\n\n";
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.*/
strength: // 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.
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 ){ // 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";
}
if ( Str >= 20 ) goto strength; // If you enter a larger number of skill points than are available, you will be asked to input a new number.
if ( Str <= 0 ) goto strength; // If you enter a less than number of skill points than are available, you will be asked to input a new number.
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.*/
agility: // 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 ){ // 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";
}
if ( Agi >= Points ) goto agility; // If you enter a larger number of skill points than are available, you will be asked to input a new number.
if ( Agi <= 0 ) goto agility; // If you enter a less than number of skill points than are available, you will be asked to input a new number.
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.*/
intel: // 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";
}
if ( Int > Points ) goto intel; // If you enter a larger number of skill points than are available, you will be asked to input a new number.
if ( Int <= 0 ) goto intel; // If you enter a less than number of skill points than are available, you will be asked to input a new number.
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;
cin.get();
}
|