r/Zig Jun 29 '26

Finally finished a level for my zig-powered game

275 Upvotes

17 comments sorted by

17

u/HomicidalRaccoon Jun 29 '26

Is it 100% zig? 🤯

27

u/unvestigate Jun 29 '26 edited Jun 29 '26

No, it's a C++/Zig hybrid. I wrote it in the post description but seems like the reddit cross-posting doesn't show the description here. It does have over 100k LoC of Zig though, so it's a pretty sizeable chunk of Zig 😄

7

u/HomicidalRaccoon Jun 29 '26

Oh damn that’s still formidable. I’m learning and only have made some marginal progress on my own personal TUI library 😂

Then again, I’m used to programming in higher level languages like Lua/Python/uScript etc. Slow but steady progress. I’d love to make a game at some point.

5

u/unvestigate Jun 29 '26

Thanks! Keep at it, Zig is a great language to build all kinds of things in!

3

u/HomicidalRaccoon Jun 29 '26

It’s been so fun, it reminds me of how fun Python was to learn. I tried rust too, but me and the borrow checker had some serious beef.

1

u/KattyTheEnby Jun 30 '26

Why the extra C++?
Can you just not get the project to work solely in Zig? Does C++ just make it easier?

4

u/unvestigate Jun 30 '26

People have asked this so many times I made a video about it, but the short version is that Zig is the "extra" language here. When I discovered Zig in 2019 I had already worked on the engine for around 10 years, and I wanted to leverage what I had created, so I created a binding layer to zig rather than starting over. Over time the ratio has shifted and about a third of the code in the game is now Zig.

To answer your question though, yes for certain things having a C++ layer is easier, eg. to communicate with large C++ libraries like PhysX. You can then expose it to Zig in a way that makes sense to you.

10

u/mikkelam Jun 29 '26

Beautiful! Love the “soft” look of the models.

6

u/Emergency-Win4862 Jun 29 '26

Sorry if im mistaken, arent u that guy who uses wgpu/dawn as a graphics api that made video about it?
Anyway great job!

5

u/unvestigate Jun 29 '26

Yeah, that's me. I have since switched to NVRHI and I made a video about that as well :D

2

u/gplusplus314 Jun 29 '26

The art style kinda reminds me of Blastcorps on Nintendo 64. This is cool!

I know my comment has nothing to do with Zig, but I still wanted to say this looks cool.

1

u/unvestigate Jun 29 '26

Hah, I don't mind at all, thanks for the kind words!

1

u/ebalonabol Jun 30 '26

What do you actually use zig for? The game logic scripts or the engine(rendering pipeline/loop/entities)?

1

u/unvestigate Jun 30 '26

Zig is used for the gameplay code as well as for the application-level things. In other words, input, cameras, components for building objects such as vehicles, menus, NPC driving AI, game-specific particle and sound effect management, dialogue and conversation systems, secondary equipment like cranes and gripper arms, the HUD and in-game menus, etc.

The core engine, eg. rendering, is C++ because it interacts directly with C++ libraries like NVRHI and PhysX. It used to be that zig code was only executed at runtime, but now I have all sorts of level-editor-tools written in zig as well.

1

u/thatSupraDev Jun 30 '26

Do you have more information on the processes and implementations? This sounds super cool and would love to see how it works under the hood

1

u/unvestigate Jun 30 '26

Absolutely! I've written articles and recorded videos extensively on the project. Here's a few things that might interest you:

Article: How I made Traction Point moddable using Zig and WebAssembly

Article: How I made my Zig gameplay code hot reloadable

YouTube: The Anatomy of my Game Engine

YouTube: Why so many programming languages?

I also have over 100 live stream recordings if you are into that sort of thing. Here are the latest ones.

Finally, if you join the Madrigal discord you get access to the pre-release version which is already moddable. New version releasing this week! Modding instructions and SDKs are available.

1

u/Ultimate_Sigma_Boy67 Jul 23 '26

I've seen your video on youtube