Hello! I am making a text-based game (I am new to C++) called The Final Journey (I made the name up, didn't copy) and I have had some trouble with the code. I am using Dev-C++ (I plan to get VC++), just so you know. Here is what I have so far:

#include<iostream.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
	system("pause");
	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;
	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;
	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	//Game Starts
	  //WAKE UP
	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here are your attributes:"<<endl;
	cout << "Health (HP): \t"<<HP<<endl;
	cout << "Strength (Str): \t"<<str<<endl;
	cout << "Defence (Def): \t"<<def<<endl;
	cout << "Energy (En): \t"<<energy<<endl;
	cout << "Army Size (Army): \t"<<Army<<endl;
	system("pause");
	cout << "Let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*You get dressed and grab your sword and shield.*"<<endl;
	  //TRAINING ARENA
	cout << "*You enter the training arena. A man is there waiting for you.*"<<endl;
	system("pause");
	cout << "Man: Hello. I am your trainer for today."<<endl;
	cout << "You: Okay, let's begin."<<endl;
	cout << "Man: Here are the instructions: I Will tell you a letter from your qwerty keyboard. The possible letters are, Q W E A S D Z X C, the left-most 3x3 of letters."<<endl;
	cout << "Man: You are to input the letter given to score a point, otherwise, you lose half a point."<<endl;
	cout << "Man: The points go to your Str and Def skills."<<endl;
	cout << "Man: READY???"<<endl;
	system("pause");
	  //TRAINING SEQUENCE
	do {
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;
	train_a = train_a + 1;
	if (rannum == 1);
	   tc2 = "Q";
	   cout <<tc1<<tc2<<tc3<<endl;
	   cin >> tin>>endl;
	   if (tin == "Q");
	      tpts = tpts + 1;
       else 
          tpts = tpts - 0.5;
    else if (rannum == 2);
       tc2 = "W";
       cout <<tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "W");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 3);
       tc2 = "E";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "E");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 4);
       tc2 = "A";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "A");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 5);
       tc2 = "S";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "S");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 6);
       tc2 = "D";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "D");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 7);
       tc2 = "Z";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "Z");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 8);
       tc2 = "X";
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "X");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    else if (rannum == 9);
       tc2 = "C"
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin>>endl;
       if (tin == "C");
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }while (train_a < 10);
    cout << "Man: Good job, you earned "<<tpts<<" points which will help your Strength and Defence levels."<<endl;
    strlvlup = (tpts / 2) / 2;
    str = str + strlvlup;
    cout << "STRENGTH LEVEL UP. YOU NOW HAVE "<<str<<" STRENGTH POINTS."<<endl;
    deflvlup = (tpts / 2) / 2;
    def = def + deflvlup;
    cout << "DEFENCE LEVEL UP. YOU NOW HAVE "<<def<<" DEFENCE POINTS."<<endl;
    cout << "Man: Good job, adventurer."<<endl;
    cout << "WOULD YOU LIKE THIS MAN TO JOIN YOUR ARMY? 1. YES, 2. NO"<<endl;
    cin >> selectnum>>endl;
    if (selectnum == 1)
       cout << "You: Would you like to join my army? You would be the first."<<endl;
       cout << "Man: Yes, I am Sir Gillington."<<endl;
       cout << "You: Okay, Sir Gillington, lets travel."<<endl;
       Army = Army + 1;
       cout << "ARMY BONUS. YOU NOW HAVE "<<Army<<" PEOPLE IN YOUR ARMY."<<endl;
    if (selectnum == 2)
       cout << "Your army stays the same size (1)."<<endl;
       cout << "Lets travel!"<<endl;
       
       
       
       system("pause");
       return 0;
}

I get these errors:
--------------------------------------------------------------------
LINE --- MESSAGE
--------------------------------------------------------------------
86 invalid conversion from `const char*' to `char'
87 no match for 'operator>>' in 'std::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(&std::cin)), ((char&)(&tin))) >> std::endl'
--------------------------------------------------------------------

Can someone please help? (And also, if the city name "Chosan" and "Cho River" are real, tell me. I came up with them by randomly pressing a few letters like this: fnoq = funoq or funoque or something like that)

Edited 7 Years Ago by bman214: n/a

#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
	system("pause");
	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;
	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;
	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	//Game Starts
	  //WAKE UP
	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here are your attributes:"<<endl;
	cout << "Health (HP): \t"<<HP<<endl;
	cout << "Strength (Str): \t"<<str<<endl;
	cout << "Defence (Def): \t"<<def<<endl;
	cout << "Energy (En): \t"<<energy<<endl;
	cout << "Army Size (Army): \t"<<Army<<endl;
	system("pause");
	cout << "Let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*You get dressed and grab your sword and shield.*"<<endl;
	  //TRAINING ARENA
	cout << "*You enter the training arena. A man is there waiting for you.*"<<endl;
	system("pause");
	cout << "Man: Hello. I am your trainer for today."<<endl;
	cout << "You: Okay, let's begin."<<endl;
	cout << "Man: Here are the instructions: I Will tell you a letter from your qwerty keyboard. The possible letters are, Q W E A S D Z X C, the left-most 3x3 of letters."<<endl;
	cout << "Man: You are to input the letter given to score a point, otherwise, you lose half a point."<<endl;
	cout << "Man: The points go to your Str and Def skills."<<endl;
	cout << "Man: READY???"<<endl;
	system("pause");
	  //TRAINING SEQUENCE
	do {
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;
	train_a = train_a + 1;
	
	//YOU NEED {}
	
	if (rannum == 1){// NOT ;
	   tc2 = 'Q'; // not "Q"
	   cout <<tc1<<tc2<<tc3<<endl;
	   cin >> tin;
	   if (tin == 'Q') // Not "Q" Not ;
	      tpts = tpts + 1;
       else 
          tpts = tpts - 0.5;
    }
    else if (rannum == 2){//NOT ;
       tc2 = 'W';
       cout <<tc1<<tc2<<tc3<<endl;
       cin >> tin; 
       if (tin == 'W')//NOT ;
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 3){// NOT ;
       tc2 = 'E';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'E')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 4){// NOT ;
       tc2 = 'A';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'A')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 5){//NOT ;
       tc2 = 'S';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'S')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 6){
       tc2 = 'D';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'D')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 7){//NOT ;
       tc2 = 'Z';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'Z')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 8){//NOT ;
       tc2 = 'X';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'X')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 9){//NOT ;
       tc2 = 'C';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'C')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    }while (train_a < 10);
    cout << "Man: Good job, you earned "<<tpts<<" points which will help your Strength and Defence levels."<<endl;
    strlvlup = (tpts / 2) / 2;
    str = str + strlvlup;
    cout << "STRENGTH LEVEL UP. YOU NOW HAVE "<<str<<" STRENGTH POINTS."<<endl;
    deflvlup = (tpts / 2) / 2;
    def = def + deflvlup;
    cout << "DEFENCE LEVEL UP. YOU NOW HAVE "<<def<<" DEFENCE POINTS."<<endl;
    cout << "Man: Good job, adventurer."<<endl;
    cout << "WOULD YOU LIKE THIS MAN TO JOIN YOUR ARMY? 1. YES, 2. NO"<<endl;
    cin >> selectnum;
    if (selectnum == 1)
       cout << "You: Would you like to join my army? You would be the first."<<endl;
       cout << "Man: Yes, I am Sir Gillington."<<endl;
       cout << "You: Okay, Sir Gillington, lets travel."<<endl;
       Army = Army + 1;
       cout << "ARMY BONUS. YOU NOW HAVE "<<Army<<" PEOPLE IN YOUR ARMY."<<endl;
    if (selectnum == 2)
       cout << "Your army stays the same size (1)."<<endl;
       cout << "Lets travel!"<<endl;
       
       
       
       system("pause");
       return 0;
}

Which compiler do you use??
------------------------------------
Where is no ";" after if()
"Q" != 'Q'
where is no endl after cin

Cho River/Chosan are from kroea.

Really? I will have to change the program then. What are the chances that I randomly come up with a real place AND river based on its name...

Which compiler do you use??
------------------------------------
Where is no ";" after if()
"Q" != 'Q'
where is no endl after cin

I use the Dev-C++ Compiler.
so you are saying I should put !='Q' instead of "Q"?

#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//intro
	cout << "welcome to the final journey v. 0.0.3 alpha."<<endl;
	system("pause");
	cout << "you are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "your homeland is chosan, a small town on the cho river. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "this... Is where you begin..."<<endl;
	cout << "the final journey."<<endl;
	system("pause");
	//variables
	  //attributes
	double hp = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double army = 1;
	  //other variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double hplvlup = 0.0;
	double deflvlup = 0.0;
	/*random integer 1-9 generator
	srand ( time(null) );
	rannum = rand() % 9 + 1;*/ //between comments ( /*here!*/ ) in random number generator.
	//game starts
	  //wake up
	cout << "*you wake up to a normal day in chosan, and your energy is fully recharged.*"<<endl;
	cout << "here are your attributes:"<<endl;
	cout << "health (hp): \t"<<hp<<endl;
	cout << "strength (str): \t"<<str<<endl;
	cout << "defence (def): \t"<<def<<endl;
	cout << "energy (en): \t"<<energy<<endl;
	cout << "army size (army): \t"<<army<<endl;
	system("pause");
	cout << "let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*you get dressed and grab your sword and shield.*"<<endl;
	  //training arena
	cout << "*you enter the training arena. A man is there waiting for you.*"<<endl;
	system("pause");
	cout << "man: Hello. I am your trainer for today."<<endl;
	cout << "you: Okay, let's begin."<<endl;
	cout << "man: Here are the instructions: I will tell you a letter from your qwerty keyboard. The possible letters are, q w e a s d z x c, the left-most 3x3 of letters."<<endl;
	cout << "man: You are to input the letter given to score a point, otherwise, you lose half a point."<<endl;
	cout << "man: The points go to your str and def skills."<<endl;
	cout << "man: Ready???"<<endl;
	system("pause");
	  //training sequence
	do {
	srand ( time(null) );
	rannum = rand() % 9 + 1;
	train_a = train_a + 1;
	
	//you need {}
	
	if (rannum == 1){// not ;
	   tc2 = 'q'; // not "q"
	   cout <<tc1<<tc2<<tc3<<endl;
	   cin >> tin;
	   if (tin == 'q') // not "q" not ;
	      tpts = tpts + 1;
       else 
          tpts = tpts - 0.5;
    }
    else if (rannum == 2){//not ;
       tc2 = 'w';
       cout <<tc1<<tc2<<tc3<<endl;
       cin >> tin; 
       if (tin == 'w')//not ;
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 3){// not ;
       tc2 = 'e';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'e')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 4){// not ;
       tc2 = 'a';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'a')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 5){//not ;
       tc2 = 's';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 's')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 6){
       tc2 = 'd';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'd')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 7){//not ;
       tc2 = 'z';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'z')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 8){//not ;
       tc2 = 'x';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'x')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 9){//not ;
       tc2 = 'c';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'c')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    }while (train_a < 10);
    cout << "man: Good job, you earned "<<tpts<<" points which will help your strength and defence levels."<<endl;
    strlvlup = (tpts / 2) / 2;
    str = str + strlvlup;
    cout << "strength level up. You now have "<<str<<" strength points."<<endl;
    deflvlup = (tpts / 2) / 2;
    def = def + deflvlup;
    cout << "defence level up. You now have "<<def<<" defence points."<<endl;
    cout << "man: Good job, adventurer."<<endl;
    cout << "would you like this man to join your army? 1. Yes, 2. No"<<endl;
    cin >> selectnum;
    if (selectnum == 1)
       cout << "you: Would you like to join my army? You would be the first."<<endl;
       cout << "man: Yes, i am sir gillington."<<endl;
       cout << "you: Okay, sir gillington, lets travel."<<endl;
       army = army + 1;
       cout << "army bonus. You now have "<<army<<" people in your army."<<endl;
    if (selectnum == 2)
       cout << "your army stays the same size (1)."<<endl;
       cout << "lets travel!"<<endl;
       
       
       
       system("pause");
       return 0;
}

thank you so much for fixing my code!!!! Omg you are awesome!!!

Do you know how to get the program to jump to a certain line of code? I want this function so i can assign passwords to different sections so if someone wants to "save" their progress, they can write down the password, and use it to get to the part of the game they were on.

PLZ HELP!!

Well, you can "Jump" To different sections using a simple goto statement. However, goto's mess up the format of your code, and therefore is bad practice. So I would recommend using while/do-while/for loops to go to different parts of your code.

If you don't care about your format, then here is a goto example:

gohere:
     cout << "Hello" << endl;
     goto gohere;

This will make the code go to the 'gohere' marker. (An infinite loop)

Well, you can "Jump" To different sections using a simple goto statement. However, goto's mess up the format of your code, and therefore is bad practice. So I would recommend using while/do-while/for loops to go to different parts of your code.

If you don't care about your format, then here is a goto example:

gohere:
     cout << "Hello" << endl;
     goto gohere;

This will make the code go to the 'gohere' marker. (An infinite loop)

So, can I tell it a certain line to go to?

if (gotocode == abc){
cout << "You have entered the code to jump to line 35."<<endl;
goto 35

I guess I could assign goto points in my code...

cout << "Welcome to line 34."<<endl;
abc:
cout << "WOOT 36!!!!"<<endl;

Edited 7 Years Ago by bman214: n/a

"goto" sux! DONT USE IT, it will make your code impossible to read!

i use think you need "goto", when you have bad program design, no question!

"goto" sux! DONT USE IT, it will make your code impossible to read!

i use think you need "goto", when you have bad program design, no question!

Well, I need to use something to jump to a line so people can save their progress. Or is there some way I can get it so it opens in the exact state it was before it closed?

Spit out a code = {0,1,2,3...} and have your code set up like this

main{
while(!correctcode(code)){
    cout>>"Gimme Code";
    cin<<code;}

if(code == 0) {//intro portion
   ...
   code = 1;}
if(code == 1) {//beat first boss
    ...
    code = 2;}
if(code ==2) {...}
}

It would essentially do the same as the jump, and you can even spit the code into a text file so they don't need to have it around.

Edited 7 Years Ago by DaBunBun: n/a

Spit out a code = {0,1,2,3...} and have your code set up like this

main{
while(!correctcode(code)){
    cout>>"Gimme Code";
    cin<<code;}

if(code == 0) {//intro portion
   ...
   code = 1;}
if(code == 1) {//beat first boss
    ...
    code = 2;}
if(code ==2) {...}
}

It would essentially do the same as the jump, and you can even spit the code into a text file so they don't need to have it around.

How do you save the code to a text file?
is there a Save or SaveAs tag?

Use fstream to print into a file.

Can you please put this into a code example for me?
is it like...

char code = NULL;
//... skip to the part that we save something...
cout << "Your code is "<<code<<". You can use that to recover your game."<<endl;
fstream<code> as <code.txt>

Is that correct?

Use some structs, classes, functions and loops in your game. You cant write a game like writing a story. You have to reuse the code you have already written like,

printMenu() // function that prints menu 
struct player
{
  int hp;
  int damage;
  int magic;

}// carries information about your character

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Just an update. I haven't worked much on this recently but I will continue work on my games if I get more people to join my website.

<URL SNIPPED>

Also, I had an idea for an RPG game played over email... Still thinking.

Edited 5 Years Ago by peter_budo: Keep It Spam-Free - Do not mention, plug or refer to any product, service, or website you are affiliated with

Since you're going to do a game,
You should have used functions so you will not have difficulty in debugging your program. At least, it would lessen the stress.:

#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>
using namespace std;


void intro() // the beginning of the game
{
cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
}

void intro2() // displays another message
{
cout << "Let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*You get dressed and grab your sword and shield.*"<<endl;

	cout << "*You enter the training arena. A man is there waiting for you.*"<<endl;
}

void TAM() // training arena (Talking to a Man)
{
cout << "Man: Hello. I am your trainer for today."<<endl;
	cout << "You: Okay, let's begin."<<endl;
	cout << "Man: Here are the instructions: I Will tell you a letter from your qwerty keyboard. The possible letters are, Q W E A S D Z X C, the left-most 3x3 of letters."<<endl;
	cout << "Man: You are to input the letter given to score a point, otherwise, you lose half a point."<<endl;
	cout << "Man: The points go to your Str and Def skills."<<endl;
	cout << "Man: READY???"<<endl;
}

void sn1() // selectnum 1 
{
   cout << "You: Would you like to join my army? You would be the first."<<endl;
       cout << "Man: Yes, I am Sir Gillington."<<endl;
       cout << "You: Okay, Sir Gillington, lets travel."<<endl;
cout << "ARMY BONUS. YOU NOW HAVE "<<Army<<" PEOPLE IN YOUR ARMY."<<endl;
}

void sn2() // selectnum 2
{
 cout << "Your army stays the same size (1)."<<endl;
       cout << "Lets travel!"<<endl;
 
}


int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	intro (); // introduction messages
	system("pause");

	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;

	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;

    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;

	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	
         //Game Starts
	  //WAKE UP

	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here are your attributes:"<<endl;
	cout << "Health (HP): \t"<<HP<<endl;
	cout << "Strength (Str): \t"<<str<<endl;
	cout << "Defence (Def): \t"<<def<<endl;
	cout << "Energy (En): \t"<<energy<<endl;
	cout << "Army Size (Army): \t"<<Army<<endl;
	
        system("pause");
	intro2(); //TRAINING ARENA texts
	system("pause");

	TAM(); // displays the conversation with the Man on the Training arena

	system("pause");
	  //TRAINING SEQUENCE
	do {
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;
	train_a = train_a + 1;
 
	//YOU NEED {}
 
	if (rannum == 1){// NOT ;
	   tc2 = 'Q'; // not "Q"
	   cout <<tc1<<tc2<<tc3<<endl;
	   cin >> tin;
	   if (tin == 'Q') // Not "Q" Not ;
	      tpts = tpts + 1;
       else 
          tpts = tpts - 0.5;
    }
    else if (rannum == 2){//NOT ;
       tc2 = 'W';
       cout <<tc1<<tc2<<tc3<<endl;
       cin >> tin; 
       if (tin == 'W')//NOT ;
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 3){// NOT ;
       tc2 = 'E';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'E')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 4){// NOT ;
       tc2 = 'A';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'A')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 5){//NOT ;
       tc2 = 'S';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'S')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 6){
       tc2 = 'D';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'D')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 7){//NOT ;
       tc2 = 'Z';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'Z')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 8){//NOT ;
       tc2 = 'X';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'X')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 9){//NOT ;
       tc2 = 'C';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'C')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    }
    while (train_a < 10);
    cout << "Man: Good job, you earned "<<tpts<<" points which will help your Strength and Defence levels."<<endl;
    strlvlup = (tpts / 2) / 2;
    str = str + strlvlup;
    cout << "STRENGTH LEVEL UP. YOU NOW HAVE "<<str<<" STRENGTH POINTS."<<endl;
    deflvlup = (tpts / 2) / 2;
    def = def + deflvlup;
    cout << "DEFENCE LEVEL UP. YOU NOW HAVE "<<def<<" DEFENCE POINTS."<<endl;
    cout << "Man: Good job, adventurer."<<endl;
    
    // First Question to the Player 
    cout << "WOULD YOU LIKE THIS MAN TO JOIN YOUR ARMY? 1. YES, 2. NO"<<endl;
    cin >> selectnum;

    if (selectnum == 1)
{
    sn1(); // displays the texts
    Army = Army + 1;
 }      
    if (selectnum == 2)
{  
    sn2(); // displays the texts
 
 }
       system("pause");
       return 0;
}

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

This is much better. :)

#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>
using namespace std;

void intro();
void intro2();
void TAM();
void sn1();
void sn2();

int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	intro (); // introduction messages
	system("pause");

	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;

	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;

    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;

	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	
         //Game Starts
	  //WAKE UP

	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here are your attributes:"<<endl;
	cout << "Health (HP): \t"<<HP<<endl;
	cout << "Strength (Str): \t"<<str<<endl;
	cout << "Defence (Def): \t"<<def<<endl;
	cout << "Energy (En): \t"<<energy<<endl;
	cout << "Army Size (Army): \t"<<Army<<endl;
	
        system("pause");
	intro2(); //TRAINING ARENA texts
	system("pause");

	TAM(); // displays the conversation with the Man on the Training arena

	system("pause");
	  //TRAINING SEQUENCE
	do {
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;
	train_a = train_a + 1;
 
	//YOU NEED {}
 
	if (rannum == 1){// NOT ;
	   tc2 = 'Q'; // not "Q"
	   cout <<tc1<<tc2<<tc3<<endl;
	   cin >> tin;
	   if (tin == 'Q') // Not "Q" Not ;
	      tpts = tpts + 1;
       else 
          tpts = tpts - 0.5;
    }
    else if (rannum == 2){//NOT ;
       tc2 = 'W';
       cout <<tc1<<tc2<<tc3<<endl;
       cin >> tin; 
       if (tin == 'W')//NOT ;
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 3){// NOT ;
       tc2 = 'E';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'E')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 4){// NOT ;
       tc2 = 'A';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'A')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 5){//NOT ;
       tc2 = 'S';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'S')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 6){
       tc2 = 'D';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'D')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 7){//NOT ;
       tc2 = 'Z';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'Z')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 8){//NOT ;
       tc2 = 'X';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'X')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    else if (rannum == 9){//NOT ;
       tc2 = 'C';
       cout << tc1<<tc2<<tc3<<endl;
       cin >> tin;
       if (tin == 'C')
          tpts = tpts + 1;
       else
          tpts = tpts - 0.5;
    }
    }
    while (train_a < 10);
    cout << "Man: Good job, you earned "<<tpts<<" points which will help your Strength and Defence levels."<<endl;
    strlvlup = (tpts / 2) / 2;
    str = str + strlvlup;
    cout << "STRENGTH LEVEL UP. YOU NOW HAVE "<<str<<" STRENGTH POINTS."<<endl;
    deflvlup = (tpts / 2) / 2;
    def = def + deflvlup;
    cout << "DEFENCE LEVEL UP. YOU NOW HAVE "<<def<<" DEFENCE POINTS."<<endl;
    cout << "Man: Good job, adventurer."<<endl;
    
    // First Question to the Player 
    cout << "WOULD YOU LIKE THIS MAN TO JOIN YOUR ARMY? 1. YES, 2. NO"<<endl;
    cin >> selectnum;

    if (selectnum == 1)
{
    sn1(); // displays the texts
    Army = Army + 1;
 }      
    if (selectnum == 2)
{  
    sn2(); // displays the texts
 
 }
       system("pause");
       return 0;
}



void intro() // the beginning of the game
{
cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
}

void intro2() // displays another message
{
cout << "Let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*You get dressed and grab your sword and shield.*"<<endl;

	cout << "*You enter the training arena. A man is there waiting for you.*"<<endl;
}

void TAM() // training arena (Talking to a Man)
{
cout << "Man: Hello. I am your trainer for today."<<endl;
	cout << "You: Okay, let's begin."<<endl;
	cout << "Man: Here are the instructions: I Will tell you a letter from your qwerty keyboard. The possible letters are, Q W E A S D Z X C, the left-most 3x3 of letters."<<endl;
	cout << "Man: You are to input the letter given to score a point, otherwise, you lose half a point."<<endl;
	cout << "Man: The points go to your Str and Def skills."<<endl;
	cout << "Man: READY???"<<endl;
}

void sn1() // selectnum 1 
{
   cout << "You: Would you like to join my army? You would be the first."<<endl;
       cout << "Man: Yes, I am Sir Gillington."<<endl;
       cout << "You: Okay, Sir Gillington, lets travel."<<endl;
cout << "ARMY BONUS. YOU NOW HAVE "<<Army<<" PEOPLE IN YOUR ARMY."<<endl;
}

void sn2() // selectnum 2
{
 cout << "Your army stays the same size (1)."<<endl;
       cout << "Lets travel!"<<endl;
 
}

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Instead of: // if statement

if (selectnum == 1)
{
    sn1(); // displays the texts
    Army = Army + 1;
 }      
    if (selectnum == 2)
{  
    sn2(); // displays the texts
 
 }

Why not: // switch statement

switch (choice);
case 1:
   sn1(); // displays the texts
    Army = Army + 1;
case 2: 
sn2(); // displays the texts

That's everything. I hope I have helped you. :)

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Like I said, I'll probably begin work on this again if I get more pope to join my site.
<URL SNIPPED>

I might come back to this, though I will probably have to start over due to the amount of time it spent untouched.

I guess I'll mark this solved. *click*
Thank you all so much for helping. Please check out my website. I could use some motivation.

Edited 5 Years Ago by peter_budo: Keep It Spam-Free - Do not mention, plug or refer to any product, service, or website you are affiliated with

This question has already been answered. Start a new discussion instead.