First off... I ran into some problems at the very beginning, and after making some changes got it to work, but I'm not sure why. This is the original code:
#include <iostream>
using namespace std;
// It won't compile like this, until I declare the Stats functions outside the class as well, why is this?
class mob {
public:
void Stats (int Hp, int Atk, int Def, int Dex);
};
class Char {
public:
char Name[10];
void Stats (int Hp, int Atk, int Def, int Dex);
};
void Char::Stats()
int main()
{
mob Witch, Ogre;
Witch.Stats (10, 10, 10, 10);
Ogre.Stats (15, 5, 9, 4);
Char Char;
Char.Name;
cin >> Char.Name;
cout << Char.Name;
return 0;
}
Here is how far I've gotten so far and to what most of my other questions will pertain to:
#include <iostream>
#include <string>
using namespace std;
class mob {
public:
char *Name [10];
void Stats (int, int, int, int, int);
};
class Your {
public:
char Name[10];
void Stats (int, int, int, int, int);
};
void mob::Stats(int Hp, int Atk, int Def, int Dex, int Spd)
{
Hp;
Atk;
Def;
Dex;
Spd;
};
void Your::Stats(int Hp, int Atk, int Def, int Dex, int Spd)
{
Hp;
Atk;
Def;
Dex;
Spd;
};
int main()
{
mob Witch, Ogre;
Your Char;
Witch.Name = {"Witch"};
Witch.Stats (10, 10, 10, 10, 10);
Ogre.Name = {"Ogre"};
Ogre.Stats (15, 5, 9, 4, 7);
Char.Name;
cout << "Input a name: \n";
cin >> Char.Name;
cout << "Your name is: " << Char.Name << endl;
int MyHp, MyAtk, MyDef, MyDex, MySpd;
Char.Stats (MyHp, MyAtk, MyDef, MyDex, MySpd);
cout << "Input your Health Points: (1-15) ";
cin >> MyHp;
cout << "Input your Atk Power: (1-15) ";
cin >> MyAtk;
cout << "Input your Def Power: (1-15) ";
cin >> MyDef;
cout << "Input your Dexterity: (1-15) ";
cin >> MyDex;
cout << "Input your Speed: (1-15) ";
cin >> MySpd;
cout << "\nAre you ready to fight?(Yes or No)" << endl;
int Value = 1;
string Response;
while (Value != 0) {
cin >> Response;
if (Response == "Yes") {
Value = 0;}
else "Are you ready now?"; }
cout << "\nThen let's begin." << endl;
cout << "Your first opponent is " << Witch.Name << endl << endl;
cout << "Ready... Set... Rumble!! " << endl;
return 0;
}
So I've done a couple baddies and stats, but I'm having a hard time figuring out how to use these to fight with.
1. To find out who goes first, I was going to include an if statement comparing my speed to the mobs, but how do I do input the speed from Witch.Stats into the if statement?
2. How would I go about changing Witch.Name on line 73 to something more flexible, so that the name of the monster would be called up like a variable(like (variable-name).Name) so based on some score system it would be able to decide who I'm fighting next.
I obviously need more then that for the game but I'll figure out the rest for myself. I've heard of DirectX and OpenGL, but I won't feel ready to start learning that until I get a better handle on C++. Finally, can anyone recommend any header files that could be used for games, offer any tips, or suggest any useful books to read on the subject?

New Topic/Question
Reply




MultiQuote








|