r/cprogramming • u/podule-games • Oct 10 '26
I'm building a game in C
I've been working on a game since about August 2020 but only recently published my Steam page.
For the Common Wealth on Steam
The game is entirely written in C, with one third party dependency, SDL3.
I chose C because I wanted to leave my options open to build for retro platforms like RISC OS and Amiga, but as the game grew, I wanted GPU acceleration and that meant leaving behind some of the retros. I'm not ruling out any ports though, if SDL3 is available on the platform.
The engine beyond SDL3 is my own, it's a 2.5D game, with levels edited in my own level editor (not in C, that's C# and Avalonia). The level editor exports levels into just plain memory dumps that are easy to read in C.
I'm trying to keep on top of a devlog here too:
Podule · Independent game studio
Writing this game in C has been enormous fun, and I have no plans to change my choice of C for future games.
5
u/tastygames_official Oct 10 '26
same here. I started out decades ago learning C but was forced into higher-level langauges and complex OOP nonsense as I became a professional programmer. But I've been making a game also with SDL3 and it's just such a great feeling actually programming instead of adhering to design patterns or frameworks. I literally was just telling my wife a few hours ago how unbelievably free and good it feels to be back in C where I belong.
Although I gotta ask - you don't use ANY other libraries? Not even for physics or math? For a 2D game I could see using simple linear physics equations and rectangle-based collision, but for 2.5D (3D but with fixed camera angle?) there's a lot of matrix math that is just pretty useless to implement yourself when there exist highly-optimized libraries. At least that's my opinion. Of course I'll never knock anyone for implementing something themselves if they enjoy doing it.
The only other libs I use are:
- cglm for 3D math (C openGL Math)
- cgltf for glTF files
- cJSON for reading extra information in the glTF files
- stb_image for reading HDR images
I've actually considered even ditching SDL and just going straight Vulkan, but I kinda like the idea of also supporting DirectX (for Windows users who may not know how to install Vulkan for whatever reason), and for the easier possibility at porting to PlayStation with few rewrites. Plus SDL is a very thin wrapper and I don't think it really affects performance that much. Especially when I remember I'm running my game at 640x480 and upscaling, so it probably doesn't even matter much...
2
u/zhivago Oct 10 '26
Plain memory dumps are not portable. :)
2
u/SnooDucks2481 Oct 10 '26
Cool project. I also did the same using webkit2gtk and combining C and javascript
2
u/Pure_Government7634 Oct 14 '26
I love this kind of game. Just like Red Alert — I've always wanted to make one of my own. I'm a programmer too, just not a game dev, and I've always held C and gamedev in a kind of awe. I always figured 2.5D games were dated, past their prime. Same with C. But seeing what you made lit that fire in me again. Maybe tech was never really "outdated" or "trendy" to begin with — or maybe none of that matters, and the work itself is the thing that shines. Man, I miss playing Red Alert as a kid. I think I'll buy a copy.
1
u/Separate-Basil-1216 Oct 10 '26
Why not use opengl directly then ?
1
u/KajiTetsushi Oct 10 '26
Sounds like a pretty sweet core tech stack!
1
u/amarukhan Oct 10 '26
Will you be integrating with Steamworks SDK? If so what library are you planning to use?
1
u/non-existing-person Oct 10 '26
It's cool and all... but I don't see the source code anywhere?
5
u/alkavan Oct 10 '26
Please consider adding just one more dependency:
Vecmat is a simple linear algebra library I wrote just for stuff like this, no other dependencies. I already implemented SDL3 graphics and a physics engine using it — but they are not part of the library and I encourage people to write their own. I did a lot of the heavy lifting so others don't need to! It has some neat features and it's modular.
2
u/goscie Oct 10 '26
Cool project, I love the old school way you doing it ! You seem like my kind of guy 😎👍
2
u/captain_slackbeard Oct 10 '26
This game reminds me of the game "Commandos" from the 90s.
1
u/Antique_Car8182 Oct 11 '26
Hey guys, I came from the automation field. Ive helped commission automation buildings in IL & GA. I’ve done automation work which involves PLCs, SCADA systems, EthernetIP, Modbus, Profinet, Profibus, and so on. I’ve graduated this year with a Robotics Certification & years back with an electrical certification. I know Python is huge in automation, but I’ve been obsessively drawn to C/C++ programming, primarily because I had a C programming course during my Robotics certification. Id like to be an embedded C programmer. I’ve been practicing coding every single day. But It seems like the more coding I learn……the more I see how much I don’t know, lol!! I love coding tho! Totally! And once I start, I’m completely addicted, so it’s hard to stop practicing and learning to Code. What path would you guys recommend for me?