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)