Category Archives: Devastro2

D2 LOG 073 – Rewrites, pt.2

Still at it with the Sokol migration and rewriting “some bits” of the game.

However, this activity has grown in scope and “some bits” now means I’ve touched almost every part of the codebase. I’m paring down many parts to make the game easier to tweak & debug.

I keep the Sokol implementation in a standalone project and keep switching between it and the full game, which still runs fine. At some point I will merge the two.

D2 log 072 – Rewriting (some bits)

While migrating the rendering & platform code to Sokol I saw a lot of my own old code. It was clumsy and convoluted. That made me happy: I could do it better now.

Decided to start a clean re-implementation of buttons and menus. I broke up the logic into smaller functions. One for the hover & click. Another for timing, to enable animating the states. And another one for keyboard navigation. The old code had all this mangled together. The new version is easier to maintain, extend and reuse.

Also changed the rendering of geometry primitives in the UI to use SDF instead of the old 9-patch technique. Much better!

I will continue with a few other bits, here and there, see how that goes.

D2 log 071 – Sokol

I’m porting my rendering code from OpenGL to the Sokol library. Sokol has a very nice low-level 3D API with multiple rendering backends (GL/Metal/D3D). It makes it much easier to experiment with new rendering techniques, especially when paired with the shader cross-compiler.

Still work in progress but I’ve done proof of concept tests for all major components of the game and everything seems to be OK.

I’m also using the Sokol app and audio libraries to completely replace SDL. The project feels much more lightweight without it.

D2 log 070 – Attack tokens

It looks ridiculous when all enemies attack the player at once. And it’s frustrating. We need to globally throttle the attack rate.

Inspired by this fascinating Doom talk, I implemented a token system. Before each attack, enemies must acquire a token for it. After the attack and some cooldown period, the token goes back into the “free” pool.

Changing the number of available tokens for each attack type and tweaking the cooldown periods are an easy way to adjust overall difficulty.

The state of the token queue can be used to determine pressure on the player. This will be a useful input for the dynamic sountrack…

D2 log 069 – Editor streamlining

While making a test level to try out some gameplay-related code I realized the editor had become a bit cumbersome to use. It was time for another round of editor improvements.

Some commands got moved into a global top menu bar, which helped a lot. Not all controls need to be always visible.

Second, I added a panel with the sorely needed list of all entities in a level. It automatically pans the camera to the selected entity and the next tab shows all its properties.

The navigation mesh was a separate layer of points and links with its own custom editing mode. I converted the navpoints into regular game entities. Same for the navmesh object which pulls them together and handles path search queries. Now the only custom code is the test mode (move origin/destination points around, editor draws the resulting path).

Finally, I upgraded all the editor icons. They were a total mess and adding new ones was a pain. Now they are all in a single Pixelmator document, ready to be exported with 1 click. The icons will not be seen by players but it helps me see quickly what’s what.

D2 log 068 – Water shader

Spent some time tinkering with shaders. It was fun but also hard to come up with something actually usable in the game.

Ended up with a subtle effect which is blended on top of the pre-rendered water surface. It doesn’t tile properly but the seam is hard to notice so I’m fine with it.

I also tried distortion for the bottom layer but UV wrapping is a problem because the tiles are in a texture atlas. Putting tiles in an array texture instead of an atlas would give me more options. Maybe next time…

D2 log 067 – Tiles, pt.3

Good progress on the tileset. I made basic outlines and shapes in Blender, then exported into Pixelmator for touchups and additional dirt layers.

First time I used Geometry Nodes in Blender. Fun!

The rest though, not so much… it’s a lot of work to make everything seamless, color matched and correctly exported. Listening to podcasts & GDC talks while working on the tileset helps a lot because it stops me from overthinking it. I really need to push through this one.

Still not the final version here; there’s an off-by-one error in my Geometry Nodes setup for the curb and one of the dirt layers is disabled.

D2 log 064 – Audio improvements

Before recording new sound effects and adding music, I want to improve the audio engine a little bit.

In this first part, I implemented some fundamentals.

  1. Envelopes. Automated adjustments of gain, pitch or pan etc. Already replaced old code for fading music in and out.
  2. Audio bus hierarchy. Apply parameters to all related sounds in one place.
  3. Lowpass/highpass filter. This has been on my wishlist since Superforce and I finally got around to it. I used this article as inspiration but the code is 100% rewritten for clarity & performance.
  4. Limiter. Safety guard to avoid clipping.

The big payoff for these features will be ducking. To make important sounds stand out, I want to suppress the less important ones. This can be done with gain but also applying the lowpass filter could make it sound even better.