this post was submitted on 20 Jul 2023
11 points (100.0% liked)

Game Development

3470 readers
7 users here now

Welcome to the game development community! This is a place to talk about and post anything related to the field of game development.

Community Wiki

founded 1 year ago
MODERATORS
 

For some time I've been trying to create some rudimentary hack'n'slash game. I didn't want to use ready game engine because I consider it more of an exercise in programming a game than an honest attempt at creating one if that makes sense. So I started with SFML.
Along the way I've recognized the need for loading settings from files(Json library), logging, map editor(ImGUI) etc and it's posing a questions to me for which I struggle to find answers to.

For example let's consider map editor. Currently loading/saving the map to file is done by TileMap class itself but I don't know if it should be. If the map is not as big as render window, should it itself be responsible for centering it or class/function using it should do it? What about scrolling map bigger than render window?

Another example is I have Entity class (player, monster can be entity) which can have Graphics, Physics component etc and it is responsible for rendering itself. But I don't know if it's the right approach. I would like to have logic separate from drawing but Entity essentially merges the two with some extra steps

Add to that is that I would like to painlessly inject debug enabled logging into different parts of this code and I'm afraid I will end up with spaghetti monster for code

What this long windup is leading to is a question. How do I write render independent, reusable game architecture? Where can I read more about this so I can make better decision about what I'm creating.

Now that I've read all of this before submitting it seems to me like what I'm really asking is "how do I make a game engine?". And this was not supposed to be exercise in creating one, at least I didn't think so when I started

you are viewing a single comment's thread
view the rest of the comments
[–] sirdorius@programming.dev 1 points 1 year ago (1 children)

I don't understand your reticence in not using a game engine. If you do this by yourself you are trying to recreate 40 years of game engine best practices by yourself. Or you can have a look at how some of the other engines do it and then try to recreate something similar. Just take a day to learn each one's architecture.

Here are the main architectures that game engines use:

  • Actor based: heavy inheritance with hierarchy based composition. Unreal, Godot
  • Component based: composition is encouraged at the entity level, reducing the need for inheritance. Unity
  • Entity Component System (ECS): No inheritance, clear separation between data and logic. Bevy, Unity DOTS

Each approach has a different solution the problems you are mentioning.

[–] spite@kbin.social 4 points 1 year ago

I do not want to recreate 40 years of best practices, I want to understand them and try to implement them. That’s why I’m asking for some reading, educational material. It’s not that I’m averse to using an engine, it’s just not something I set out to do