SFML community forums

Help => General => Topic started by: myroidtc on August 12, 2016, 06:13:18 am

Title: Allocating the entire game on the heap
Post by: myroidtc on August 12, 2016, 06:13:18 am
I have an Engine class that holds the SFML loop and everything else the game needs to run. In the main() function, I declare the Engine with a unique_ptr and run it like so:

int WinMain()
{
    std::unique_ptr<Engine> engine = std::unique_ptr<Engine>(new Engine());
    engine->run();
    return 0;
}
 

Can anyone explain if/why this is a horrible idea?
Title: Re: Allocating the entire game on the heap
Post by: Laurent on August 12, 2016, 08:06:12 am
It's not a horrible idea, you're just overcomplicating it.

int WinMain()
{
    Engine engine;
    engine.run();
    return 0;
}