River Rapids, the making of 1

thomastc • 1 year ago on 17th Alakajam! entry  River Rapids

Having taken part in every single main Alakajam event until now, it sometimes feels like I'm getting stuck in a rut. So this time, I decided to shake it up a little by (a) using the latest Godot 4 release candidate, instead of the stable 3.5, and (b) going full 3D instead of my usual 2D style:

I had a slow start due to other obligations, which gave me some time to think about the game design. Most of that made it into the final game, but I had some ideas that didn't work as well as I'd thought.

Originally I had implemented tiles with forks (three exit points). The idea was that the river goes down a slope, so the boat would always pick the most downwards direction. If there were multiple options, it would choose randomly. This means the player would need to take both possibilities into account until the boat had made it to the fork. However, it was still possible to make a corner where the river is forced to go upwards, which then wouldn't make physical sense. Should the boat get stuck, or start moving against the flow? Neither would be a great option. Moreover, I found during playtesting that it was easy to always point the "unwanted" exit point upwards so that it always got ignored. We could also say that the river is on a flat plane, and always choosing a random fork regardless of up/down direction, but this made the game too unpredictable.

The other idea that didn't make it was multiple boats. This would have interacted nicely with forks and joins: you'd have to make sure that the boats didn't collide. You could send both down the same path, making it easier to manage, or maintain two parallel paths to increase coverage for collecting stars. I think this idea could have worked, but didn't implement it because time was up.

Godot 4 was a very smooth experience. My entire X server crashed once, but that's unlikely to be Godot's fault; otherwise everything was pretty stable. The editor feels snappier than Godot 3 and has grown a couple of new useful features. I had some trouble with the export, but it turned out it was my own fault. I was listing files in the levels/ directory to enumerate levels at runtime, but didn't realize that the file names change upon export. Easily fixed with some hardcoding.

Working in 3D was the challenge. Having worked with Blender years ago in the days before the huge 2.5 overhaul, I had to re-learn it on the spot. Fortunately I only needed basic mesh creation and manipulation facilities; everything else could be done in Godot, including textures and materials.

Several hours went into writing shaders. The water shader is the most apparent one. It takes two noise textures, A and B, and lerps between them, using a sawtooth mix factor that ping-pongs between 0 and 1 over time. When the factor is 0, texture B (which is entirely invisible at that moment) is translated to a new location, and vice versa. This avoids a repetitive effect.

The other shader, which is not nearly as apparent, is the one that draws the terrain. The albedo comes from another noise texture, which is put through a gradient map to get some colour variety. Another noise texture is used as a normal map. That same texture is also used as a height map to displace the vertices. You might think I just produced three models for the three different tile shapes (straight, obtuse corner, acute corner), but no: the river is also carved out using the shader.

The water on each tile is just a single plane mesh that intersects the terrain. Unfortunately, that means you can see its edges glitching through the side of the tile sometimes. The obvious quick fix of shrinking the water mesh slightly resulted in the river having seams, which looked worse, and I had no time to fix it properly. The price for working in 3D, I guess.

All texture sampling is done in world space coordinates so that tiles and water match up seamlessly. However, for the tile queue on the right and the "ghost" tile attached to the mouse cursor, local coordinates are used so that these tiles don't seem to change while they move. As a result, when you place a tile, it switches from local to global coordinates and does change shape a little, so I put some smoke particles on top, tweened the vertical coordinate, and added some camera shake, all to make it less noticeable.

Changing the colour scheme for each level was an addition half an hour before the deadline. It's a pretty quick way to add some variety. Because it was done in such a hacky way, the colour of the river on the main menu also changes according to which level you last played, which is actually a bug but I'm branding it as a feature now!

Play it now!

Comments (1)

voxel
 • 1 year ago • 

Great writeup (sometimes my favourite part of the jam)! Looking forward to playing this soon once I have time to take a good look at the submissions

Login to comment