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

  • 🇰 🌀 🇱 🇦 🇳 🇦 🇰 ℹ️@yiffit.net
    link
    fedilink
    arrow-up
    3
    arrow-down
    2
    ·
    edit-2
    1 year ago

    The first thing I ever learned in programming was never to reinvent the wheel. If you already aren’t a pro at making your own engine and you didn’t set out to make an engine, why are you making your own engine when there are plenty that have everything you need to start doing what you really wanted to in the first place? I myself have a desire to make an engine; but I can’t even find a justification to try because there isn’t anything I think I could do better than what has already been done, and nothing I could add thay I couldn’t just put into an existing engine.