Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Allocating the entire game on the heap  (Read 855 times)

0 Members and 1 Guest are viewing this topic.

myroidtc

  • Newbie
  • *
  • Posts: 38
    • View Profile
    • Myroid-Type Comics
    • Email
Allocating the entire game on the heap
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Allocating the entire game on the heap
« Reply #1 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;
}
Laurent Gomila - SFML developer

 

anything