But, I'm getting a few errors and can't figure out why they would be occuring.
So far Ive coded the player to input his/her name.
Then for the player to attack an opponent or heal him/herself.
But I think Ive defined a few variables incorrectly.
I was hoping someone here might be able to check over it?
I'd appreciate it.
Even just guidance in how to correct them would be good.
//Author: Jaimie Warburton
//Date: 18 March 2008
//Title: RPG game
#include <windows.h>
#include <conio.h>
#include <iostream>
using namespace std;
//This is line 10--------------------------------------------------------------------
int main ()
{
// Define Variables
string name;
int userchoice;
int attack;
int heal;
int StartHealth = 100;
int EnemyStartHealth = 100;
int PlayerHealth; //this is line 20
int EnemyHealth;
//User inputs name.
cout << "Hello, \n";
cout << "What is your name? \n";
cin >> name;
cout << "Hello " << name; ". \n";
Sleep(3000);
system("cls");
//this is line 30----------------------------------------------------------------
//Switch statement for user attack/heal choice.
cout << "You are being attacked. \n";
cout << "What would you like to do? \n";
cout << "Press, \n";
cout << "1. To attack. \n"; // Attack opponent
cout << "2. To heal. \n"; // Heal self
cin >> userchoice;
//Switch statement
switch(userchoice) //line 40--------------------------------------------------------------
{
case 1:
attack = "%40";
cout << "You decided to attack. \n";
cout << "You hit for " << attack ". \n";
EnemyHealth = EnemyStartHealth - attack;
cout << "The enemy has " << EnemyHealth " remaining. \n";
break;
case 2: //line 50----------------------------------------------------------
heal = "%30";
cout << "You decided to heal. \n";
cout << "You have recovered " << heal " health. \n";
PlayerHealth = PlayerHealth + heal;
cout << "You now have " << PlayerHealth " health.";
break;
}
getch();
return 0; //line 60------------------------------------------------------------
}
and the errors:
In function `int main()':
line 43 invalid conversion from `const char*' to `int'
line 45 expected `;' before string constant
line 47 expected `;' before string constant
line 51 invalid conversion from `const char*' to `int'
line 53 expected `;' before string constant
line 55 expected `;' before string constant