Zig feedback from a game developer (Dirtbike sim dev)

Writing shaders in zig would be incredible :slight_smile: Looking forward to it!

1 Like

Woohoo! Woohoo!
[post needs to be at least 10 chars… :slight_smile: ]

4 Likes

This makes me very happy, and will be a really exciting addition to the language. :grin:

Being able to write your GPU code in Zig is a really nice feature, not one that exists and/or is easily accessible most other general purpose languages. I imagine it will make it attractive to AI developers, but I am personally just excited about it for the game-dev possibilities.

3 Likes

I’m pretty sure it always worked with try. Here is feature description from when it was first implemented. It doesn’t work with catch tho maybe you mixed them up

2 Likes

(regarding memory management and shrinking/growing memory)

Also, games typically oscillate around a predictable max memory usage, and object lifetimes can be roughly divided into a handful of buckets:

  1. ‘static lifetime’, e.g. created at startup and destroyed at shutdown
  2. ‘level/zone lifetime’, e.g. created during the ‘lifetime’ of a map/level/zone/region and bulk-destroyed when that area is left
  3. ‘frame lifetime’, created at some point during a frame and bulk-destroyed at the end of the frame
  4. ‘unpredictable’ anything else, although here various strategies make sense to still avoid fine-grained per-object lifetime management and unlimited growth.

For anything in the ‘unpredictable lifetime’ category I would use a fixed-size pool where items are only marked as dead and the oldest dead item will be recycled when a new item is needed. For instance for something like killed monsters you’d want their carcasses to still be around, but at the same time don’t want to pile them up beyond a maximum number.

…or for bullets (here I wouldn’t use a fully fledged game object per bullet, but something more lightweight more akin to a particle system).

Inventory items can also be fully virtualized instead of being actual game objects. E.g. just build the inventory system completely separate from the rest of the game.

Etc etc etc… IME it’s especially dangerous/tempting in games to run into the ‘everything is an object trap’, because most games deal with representations of actual physical objects.

5 Likes

I agree that it’s a good time to try out bespoke engines. Great video

1 Like

After 7 months, I’ve got a new video for my Dirtbike sim! Still having a good time with zig :slight_smile:

https://youtu.be/MRQpUHUC_8Y

9 Likes

This looks incredibly well designed. Really cool to see this.

Are you planning on including a game mode inspired by those old 2D dirtbike flash games where you have to cross seemingly impossible terrain, often uphill with big boulders, but turns out you can do it with pure skill and endless patience?

1 Like

Thank you!

Haha yeah there’s a whole genre of dirtbike racing called Hard Enduro where you do this :slight_smile: Those guys are nuts. Going to have some challenges involving it for sure.

2 Likes

:ok_hand: I will have fun watching videos before bed tonight

1 Like