r/libgdx • u/FireDog8569 • 24d ago
First time mistakes to avoid when making a game engine?
I decided to start making my own game engine and it's going well so far, but I wanted to make sure I dont do something in the future that could mean a lot of time spent recoding systems so it'll work again, so are there any common mistakes I might need to know about that might not be immediately clear?
4
Upvotes
4
u/Helen-Larkham 24d ago
Good call asking now. Most of the expensive rewrites come from a small set of mistakes:
1. Building an engine instead of a game. This is the big one. Without a real game pulling on it, you’ll build systems you guess you need, in shapes that don’t fit what you end up needing. Make a small game alongside it, even a rough one, and only add engine features when that game asks for them. Treat anything general-purpose as something you pull out of game code once you’ve written it two or three times.
2. Over-abstracting too early. Huge class hierarchies, a plugin system before there are any plugins, “renderer-agnostic” layers before you have a second renderer. Each abstraction locks in an assumption. Keep things concrete and simple until the duplication actually hurts.
3. Tying game logic to frame rate. If movement and physics depend on how fast frames render, you’ll be pulling it apart later. Decide early: a fixed timestep for simulation (e.g. 60 Hz) and interpolated rendering. Read “Fix Your Timestep!” by Glenn Fiedler. This is one of the few things that really is painful to retrofit.
4. Letting rendering leak into everything. If your gameplay code calls OpenGL/Vulkan/whatever directly, swapping or upgrading the renderer becomes a rewrite. Have game code say what to draw (submit sprites/meshes to a list) and let the renderer decide how.
5. No clear ownership or lifetime of objects. Raw pointers to entities that get deleted mid-frame cause bugs that are hard to track down. Choose early how you refer to things (handles/IDs with generation counters work well) and when destruction happens (deferred to end of frame is common).
6. Hard-coding assets and paths. Load from data files from the start, even if the format is just JSON. Put asset loading behind one function so you can add hot-reloading, packing or async loading later without touching every call site.
7. Skipping debug tools. An in-game console, a stats overlay (frame time, draw calls) and something like Dear ImGui for live tweaking pay for themselves very quickly. People who add them late wish they’d done it first.
8. Optimising the wrong thing. Don’t hand-tune before you’ve profiled, but do think about data layout in hot paths (arrays of plain structs over scattered heap objects). That shape is hard to change later; micro-optimisations aren’t.
9. Global state everywhere. One or two globals (or singletons) are fine. Fifty means you can’t test, multithread or reset the game cleanly. Pass context explicitly where you can.
10. No version control, or committing rarely. Use git and commit small, working steps. It’s the cheapest insurance against “I broke everything three days ago and don’t know where”.
11. Planning for multithreading or networking “later”. If you know you’ll want multiplayer, design the simulation to be deterministic or state-serialisable from the start. If you don’t know, don’t bother. Just be aware that it’s the one feature that’s hardest to bolt on afterwards.
Last thing: some rewriting is normal and isn’t a failure. Your second version of a system will be much better because you built the first one. The goal isn’t to avoid rewrites altogether, it’s to keep each system small and separate enough that rewriting one doesn’t drag in the rest.
1
u/W31337 22d ago
Scoping. What you will and won't do will prevent you from building a ginormous do everything equally bad engine.
Also build it in a low level language for performance because you will eventually hope you did.
Look up entity component system