Remix.run Logo
hnthrowaway0328 2 days ago

Can absolutely relate and understand.

I taught myself C++ by writing games with SDL2.

The first game -- snake took about a couple of hundred lines and I put everything in one .CPP file. And I felt pretty good.

The second game, well, I forgot what it is, not Tetris nor Breakout, but it was complex enough that I realized that I need to put code into header files and source files.

The last game of that project was a Ultima-spinoff. I even used the same sprite sheet. The complexity completely drowned me. I was constantly asking myself how should I arrange things properly so I don't need a lot of global variables that every file can see, because naturally the Game class needs to see and know all other classes, and the Renderer class needs to see and know many other classes too, etc.

Eventually I dropped the project. A few years ago I picked it up again and figured out something that is close to Entity - System (not ECS just ES). I didn't complete the project but then firmly believe that it was the right architecture, and I was simply too burnt out to complete it.

This year I learned about ECS from pikuma. I think it's over complicated for small-medium games. Anyway I'm trying to say that I agree that writing a 10,000 line project is way more complicated than 10 1,000 line projects.

wavemode 2 days ago | parent | next [-]

Unrelated to the central point of your comment, but I've also found that a simple entity system is usually perferable to ECS for smaller games. ECS aids performance, but performance usually isn't what you're struggling with in a small indie game. You're mainly just struggling to organize your code, and just need something simple to help manage complexity.

randysalami 3 hours ago | parent | next [-]

I built an ECS from scratch back in 2019 using C#. It was my first programming project in earnest and I was 19 at the time. Fortunately, I committed to version control and sometimes I still look at it: https://github.com/randyselimi/ECSRogue

I came up with everything on my own and I don’t know how I was so inspired then. Most of the ECS code is in a folder tilted Partis (that was the name of the ECS system I wanted to develop)

randysalami 3 hours ago | parent [-]

Probably my favorite piece of code is in ECSRogue/Partis/Entities/EntityIndexManager.cs. I’d love if someone with more experience could critique this code and my implementation. Keep in mind, I just transferred from community college and hadn’t even taken a single programming/data structure course

LoganDark 2 days ago | parent | prev [-]

Minecraft is an entity system and it seems to work just fine. (Fun fact: Forge Mod Loader makes Minecraft an entity component system.)

immibis 15 hours ago | parent [-]

having things called entities and components isn't doing ECS. Minecraft is a traditional OOP class hierarchy of entities, which (with Forge) have a Map<String, Object> whose entities are called components.

In the technically superior Fabric ecosystem, you can add fields directly to the entity class using bytecode modification instead of having HashMap overhead on everything. Accessing them is a bit roundabout, but in a way the JIT compiler can optimize.

jart 2 days ago | parent | prev [-]

Adopting an existing well-established style guide is a good way to make these sorts of questions go away. https://google.github.io/styleguide/cppguide.html