Game Development Reference
In-Depth Information
Sword m_sword;
Chest m_swordChest;
using Enemies = std::vector<Enemy::Pointer>;
Enemies m_enemies;
bool m_playerQuit{ false };
void InitializeRooms();
void WelcomePlayer();
void GivePlayerOptions() const;
void GetPlayerInput(std::stringstream& playerInput) const;
void EvaluateInput(std::stringstream& playerInput);
public:
Game();
void RunGame();
virtual void HandleEvent(const Event* pEvent);
};
Game now references the Option and Enemy instances via a type alias that is defined in the respective
Option and Enemy class definitions. These aliases are shown in Listing 23-4.
Listing 23-4. The Option::Pointer and Enemy::Pointer Type Aliases
class Option
{
public:
using Pointer = std::shared_ptr<Option>;
protected:
PlayerOptions m_chosenOption;
std::string m_outputText;
public:
Option(PlayerOptions chosenOption, const std::string& outputText)
: m_chosenOption(chosenOption)
, m_outputText(outputText)
{
}
const std::string& GetOutputText() const
{
return m_outputText;
}
virtual void Evaluate(Player& player) = 0;
};
 
Search WWH ::




Custom Search