1

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.

top 3 comments
sorted by: hot top controversial new old
[-] alejandro@kbin.social 1 points 1 year ago

The game engine is the integration point for your content. If you're running into architectural issues that require you to start afresh, it's probably because you haven't figured out the requirements for your game and the type of content it requires. For example, if you're making a Super Mario clone, then it's pretty easy to design an engine for it since you know exactly what the game will look like at the end. Like @boaratio suggested, don't try making a generic off the shelf engine, which is something you'll inadvertently do if you don't know what game you're making.

Then spend some time learning about game engine design. The book "Game Engine Architecture" by Json Gregory is a good introduction, and probably all you'll need. It's kind of short and doesn't go super deep on anything, but it does give you good perspective on everything, and is a good jumping off point for everything else. This ebook also has good content: https://gameprogrammingpatterns.com/ (in particular, read the chapter on state machines)

[-] boaratio@kbin.social 1 points 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!

[-] TerabyteRex@kbin.social 1 points 1 year ago

if you arent using a game engine then you are creating a game engine. i found this out using monogame with c#. monogame has tons of classes to help you and even a game loop but there is still so much to build

this post was submitted on 15 Jun 2023
1 points (100.0% liked)

Gamedev

5 readers
1 users here now

founded 2 years ago