Restarting into game dev using C - Anyone have any advice?
Long story short, I tinkered around learning C++ in high school in the Half-Life SDK days (~2001 and on). I'm a competent enough programmer, but that never became my profession - see Sr. IT engineer instead.
Anyway, I'm interested in doing programming again; specifically game programming. I spent the past couple weeks hammering through learning modern C via the books: "Modern C," and "Fluent C: Principles, Practices, and Patterns." I'm surprised how natural it all feels again and picked up quickly. However, using a non-OOP language really makes me think hard about implementing concepts that were so familiar and natural in C++.
Currently, I'm thinking through two concept that are going to be a foundation in the engine I'm making for my game - a light-hearted, isometric 2D RPG without turn-based fighting. I'm using C11, RayLib, and nothing else (possibly OpenMP if I delve into threading). I would like to make this Linux and Windows cross-compilable. I'd love links to articles and videos or just some guidance in general on these sorts of things:
-
In ECS (Entity Component System), it's best to use composition over inheritance (the latter being "impossible" in C). What might be a good approach to implementation of an ECS in C? I'm thinking about using ENUMs that you assign to entities that dictate their composite properties. e.g. ENUM1 = {static, dynamic, trigger}, ENUM2 = {dumb,think}, ENUM3 = {npc, enemy, item}, etc. From there I would use an entity management ABI (Application Binary Interface) to manage them and call functions for each one as needed. Being efficient about entity processing each game loop leads me to my next point...
-
Implementing a non-O(n^2) algorithm/structure that I can use to efficiently manage the entities in the game at any given time. I know quadtrees are popular, but I may not need such a complex and scaled solution for my needs. I couldn't imagine anything more than a couple hundred entities on screen at any given time. Utilizing my Google-foo, I came across a stack overflow post where someone asked about a demonstration of a quadtree implementation. Someone was kind enough to make an amazing post, but they mentioned a some optimization strategies. They said they were a fan of a grid-based system over a dynamic quad tree system. From what I can gather, I think they define a static grid tree structure where they simply compute where entities belong (which grid segment). I suppose it's still a tree structure? It sounds more or less like a quadtree, but I was wondering if anyone may know something more about this. This may be just what I'm looking for, by the sounds of it.
Thanks in advance for any help!
Posted Dec 19, 2023, 7:05 AM UTC