If I just have C++ and say SDL or Raylib, how do I structure game code to keep it scalable (ie not a huge mess when I add more levels, items, mechanics, etc)? I have been able to make very simple stuff but the moment I try to add to it, it always gets out of hand and I can’t really refactor it without starting fresh.

  • boaratio@kbin.social
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    As someone that has been a professional developer for 20-ish years, and has always dabbled in game development since I was a kid, I can share a couple bits of advice. I’ve written a couple different purpose built engines, and have used a few of the current popular ones as well.

    • Plan your engine before you write a single line of code. It’s fine to do some experiments to work out the technical details of your chosen language/library, but don’t just start coding without planning.
    • Draw a diagram (whether it’s UML or something less formal) of what your engine would need to look like to accommodate the type of game you’re making.
    • Don’t attempt to make a general purpose engine that is fit for any type of game - make sure it works for your chosen game/genre because designing the kitchen sink of engines is futile.
    • Don’t fall prey to the current design paradigm de jour. First it was Entity-Component Systems, then it was Behavior Trees, etc. I know that OO Design has fallen by the wayside, but attempting to learn some new game development/engine methodology in addition to making a game is going to be way more work than it’s worth. More often than not, the simple solution is the best one.
    • Don’t be afraid to refactor. If you’ve programmed yourself into a corner where your engine is hampering your content additions, walk away, and come back with a fresh perspective to see if refactoring can save you time and headache.

    I know none of this is specific to any particular language or tech stack, but that’s the point. Don’t get bogged down in the minutia of it, and instead focus on the big picture. I hope that at least helps a bit - and be sure to share your progress!