Say I'm creating a game that has two classes. The player class and enemy class. The player makes a choice, and the enemy has to make a choice as based on the players. For example, in Pokemon you choose your starting pokemon, if you pick a Cyndaquil or Charmander, your rival will automatically pick a Squirtable or Totodile. How would I do that ?
1 reply to this topic
Sponsor:
#2 Members - Reputation: 136
Posted 16 March 2012 - 12:02 AM
I'm a bit confused on what you said, But as far as i read.
Or you can simply use Inheritance to just directly acces the boolean choice and update everything in the enemy class. Its all upto you.
class Player
{
private:
bool charmander;
public:
Player();
void SetPokemon();
bool getChoice();
};
Player::Player()
{
charmander = false;
}
void Player::SetPokemon()
{
if( //condtions met here.. )
{
charmander = true;
}
}
bool Player::getChoice()
{
return charmander;
}
class Enemy
{
public:
void SetPokemon( bool choice );
};
int main()
{
Player thisPlayer;
Enemy thisEnemy;
thisEnemy.SetPokemon(thisPlayer.getChoice());
//Do all the stuff;
}
Or you can simply use Inheritance to just directly acces the boolean choice and update everything in the enemy class. Its all upto you.






