Building an Engine, Part 3: The Foundation

VolythEngine has a foundation now. Not “it draws a room” anymore: a foundation you could build a whole game on. It also has its first map that isn’t a test room, a dark, empty place called Gloom.

This post is about what the foundation is, and how it got built without falling over. If you’re new here, Part 1 covers how VolythEngine gets made.

What’s in it

Rendering. The low-res Quake look, baked lightmaps with bounce light, flickering and switchable light styles, fog, liquids you can see into, two kinds of sky, and dynamic lights for muzzle flashes and explosions.

The editor. Drawing, clipping, carving and hollowing brushes, vertex editing, texture lock, prefabs, a leak finder, a console, a TrenchBroom-style toolbar, and a play button that drops you into the level you’re building.

The game. Quake-style movement, doors, lifts, trains, triggers, secrets, saving and loading, menus and settings. There are monsters and weapons too, but they’re placeholders on purpose. More on that below.

Sound. Positional audio, ambient loops placed in the map, footsteps that change with the surface, and walls that muffle what’s behind them.

Scripting. Each map can have a small script that reacts to the level: opening doors, playing sounds, hiding and showing things, and starting timers.

Tooling. One command bakes lighting. Another restores every third-party asset from a manifest that records where it came from and its licence. There’s a texture tool, packaging for release, and a 17-page wiki.

How it got built

A pile of features isn’t a foundation. A foundation is a pile of features you can trust. Here’s how that trust got built.

Small milestones. Every milestone is broken into tasks small enough to finish and check in one go. There have been 147 of them, and every one ends with everything passing.

Nothing counts until it’s checked. That’s my rule from day one, and it has grown teeth. There are 1,454 tests. Anything visual gets a screenshot that has to be looked at. And the game can now play itself from a script: a .play file says “face this way, run, jump”, and the run logs exactly where the player ended up and what happened on the way. Gloom’s whip course is tested that way, start to finish.

Every decision is written down. 351 of them so far, each with the reason, and the alternatives that lost. When something seems odd months from now, the answer is a search away.

Mistakes stay on the record. The devlog doesn’t hide them. One entry, word for word: “Fixed my own mistake: script-spawned pickups weren’t really saved (only dropped cells were).” The log is full of lines like that, and I trust it more because of them.

And then I play it. This is the part that changed most recently. Once the foundation was solid enough to play properly, a lot of my time shifted from writing specs to playing it and chasing down whatever felt wrong. A few things that came out of that:

That last one deserves a confession. In Part 2, I wrote that the visibility set was “never allowed to draw too little”. It did. Rendering 22 views of Gloom with and without it showed the problem: 21 were identical, and one, looking out of the ruin through a narrow window, was missing 1,312 pixels. Every sampled line of sight had missed the gap. It was only saving about 2.5% of the triangles anyway, so it’s now off unless you ask for it. Automated checks catch a lot. A person walking around catches the rest.

Gloom

I wanted a darker, gloomier map with no monsters: just terrain, and eerie Quake-style ambience.

Gloom: the canyon, the basin, the ruin, and the slime grotto.

Gloom: the canyon, the basin, the ruin, and the slime grotto.

Gloom is a narrow rock canyon under cold moonlight, a ramp down into a foggy basin with a sunken pool, a roofless brick ruin with broken columns, and a tunnel through the rock to a grotto with a glowing slime pit. A low drone plays everywhere, with wind in the open, drips by the pool and bubbling at the slime.

The interesting part is how it’s built. I built Gloom entirely with VolythEngine’s own editor tools, boxes, wedges, cylinders, hollows and carves, and saved it as a normal map file, so the map doubles as a test of the editor. A second test walks a player from the canyon, down the ramp, through the ruin and the tunnel, and round the slime pit to the far side of the grotto. The first route it tried cut across the pit’s corner and fell in.

The first bake was too dark, even for Gloom: the canyon floor was nearly black. The moon, the sky glow and the ambient light all went up, and now it’s dark in the way I wanted, not dark like a broken monitor.

Gloom in the editor, with the new TrenchBroom-style toolbar and the map’s ambient sounds in the scene tree.

Gloom in the editor, with the new TrenchBroom-style toolbar and the map’s ambient sounds in the scene tree.

A place to try things

With no monsters in the way, Gloom became the place to try new ways of moving. These are design calls, and they’re mine.

The whip. Crack it, or look at an anchor and hook on, run for momentum, swing, and let go once you’re past the high point. Eventually the crack will stun monsters and hit switches too. Gloom has a gallery with a pit under a brick arch to swing across, a corner to swing round, and a rock face to climb on the rope.

Cracking the whip in Gloom’s gallery.

Cracking the whip in Gloom’s gallery.

Climbable walls, the way Ocarina of Time does them. Walk into vines or a lattice and you hold on, climb up, down and across, and pull yourself over the top or in through a window.

The lattice up the side of the tower.

The lattice up the side of the tower.

Sticky ground. A floor of flesh that slows you, drags at every step, and squelches. Gloom has a tunnel of it to wade through.

The flesh tunnel. It’s worse with sound.

The flesh tunnel. It’s worse with sound.

This is also why the monsters and weapons are placeholders. Shooting things is solved; Quake solved it in 1996. Moving through a strange place is where I want the game to be different, so that’s where the effort goes.

What changes now

With the foundation down, the question stops being “can the engine do this?” and becomes “what should the game be?” That’s a much better question to be stuck on. Gloom is the first answer: a dark place, a whip, and a lot of ways to get from one end to the other.