I'm making a game with a debugging console. It is structured like:
class Game
{
bool debugMode;
// ...
std::unique_ptr<Loop> loop;
std::unique_ptr<Debugger> debugger;
// ...
}
It works great in the class functions:
void Game::init()
{
// ...
loop = std::make_unique<Loop>();
if (debugMode)
{
debugger = std::make_unique<Debugger>();
debugger->console->write(L"Game initialized."); // works great!
}
}
But what if I want to write something to the console in loop
?
- I don't want to pass
debugger
toloop
. - I don't want to create another
debugger
inloop
.
How do I give loop
access to debugger
?
Aucun commentaire:
Enregistrer un commentaire