Hacker News new | ask | show | jobs
by EvanKelly 1768 days ago
I've always wanted to understand how a game like this actually runs, but always struggled with navigating through a project. I'm adept at reading and understanding code, but struggle to understand aa big project like this.

Where does one start when looking at a github like this - where's the "game loop" actually live?

1 comments

Haven't looked at this particular project, but most code is way too big and has way too much indirection so it's not clear where stuff happens just from browsing the code. I recommend setting up the project in an IDE / debugger and stepping through the code.

To substantiate my point, here is an excert from the main function of the OP game.

    WLApplication\* g_app = nullptr;
    try {
        g_app = WLApplication::get(argc, const_cast<char const\*>(argv));
        // TODO(unknown): handle exceptions from the constructor
        g_app->run();

        delete g_app;

        return 0;
   } catch (const ParameterError& e) {
   //  handle wrong commandline p
Before anything of value happens, there is already a function call where it is impossible to find the called code with a simple text search. How the hell are you supposed to figure out where "get" lives (it's probably not prefixed by "WLApplication::" at the definition site)? You need at least an IDE with a solid "go to definition" feature. But likely that won't be enough since a lot of the stuff will only be resolved at runtime.

If you want to learn architecture, I would recommend trying to do your own stuff and then to follow along with Casey Muratori's streams. While his streams are extremely verbose, he is a skilled communicator and most importantly he is one of the few persons on the planet who has figured out how to write modular software. (Very little of the stuff that makes modern software inscrutable - like OOP method syntax, inheritance, virtual functions, function pointers).

grep ‘ass WLApplication’ should do it, no?
That would find you the class, not the implementation of the get() function in it.

And what if it is a namespace?

So my point is how complicated (and thus unergonomic) the simplest things are made without any evident reason.