Skip to main content

Game dev

Posts about game dev

The cover of "Ten years of Capture The Flag"

Ten years of Capture The Flag

Ten years ago today, I uploaded the first version of Capture The Flag. Capture The Flag is a multiplayer game where two teams of players battle to claim the other team’s flag whilst defending their own. Capture The Flag is played in a destructible voxel environment, allowing players to build defences and place traps.

Capture The Flag started life as a persistent kingdoms game but quickly pivoted to a match-based team game. It was developed iteratively, taking into account player feedback. I hosted a server for the game for many years and a community formed around it. In 2021, I handed over the reins to CTF to very capable hands; it remains Minetest’s most popular server to this day.

This article covers the history of CTF, the lessons I learned, and the changes I made along the way.

Read more of "Ten years of Capture The Flag"

The cover of "Make games not engines: why I'll be using Godot engine"

Make games not engines: why I'll be using Godot engine

One of the reasons I learned how to program was to make games. Games are a unique form of creative medium, combining art, interactive storytelling, and vibrant worlds. But as a software engineer, it’s easy to lose sight of my goals and get trapped by the technical details. It’s common for software engineers in game dev to roll their own engine, which I believe reduces productivity and is ultimately a distraction to making a game.

Note that I’m not just referring to making reusable or generic game engines; for this article, I consider using low-level technology like OpenGL, SFML, or SDL to make games to include the act of rolling your own game engine, even if the focus is specific. It’s more manageable, but you still end up reinventing the wheel and having to solve many of the same problems.

There are plenty of other articles about whether or not to make your own game engine. This article is personal to me; it’s an exploration of my journey in game dev, a discussion of what motivates me, and a promise for the future.

Read more of "Make games not engines: why I'll be using Godot engine"

The cover of "SDL_GameController: Making gamepads just work"

SDL_GameController: Making gamepads just work

When implementing controller support in a game, it’s desirable for gamepads to just work without a lot of user configuration. Platform APIs are pretty useless for this, the solution is an API like SDL_GameController that allows you to target a large number of gamepads without much effort.

Each operating system has its own API for gamepad input. Windows has XInput, and Linux has the joystick and evdev APIs. When a gamepad button is pressed, applications will receive a button id. This is a number, there’s no OS way to know which button id corresponds with which button. The ids for a button are not the same on different gamepads and platforms, making it super hard to support more than a couple of devices.

if (SDL_JoystickGetButton(joystick, 8)) {
    std::cerr << "no idea what button 8 is" << std::endl;

One thing platforms do give you is the name, model, and manufacturer of the game controller. If you test with a large number of gamepads, you can create a database from gamepad name to layout. Luckily, SDL_GameController has already done this for you. Instead of a random number, you can use a named button that will work no matter the gamepad and platform:

if (SDL_GameControllerGetButton(controller, SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_X)) {
    std::cerr << "X was pressed!" << std::endl;

Read more of "SDL_GameController: Making gamepads just work"

The cover of "Creating worker NPCs using behavior trees"

Creating worker NPCs using behavior trees

I’m a huge fan of RimWorld, a base building game where you manage a group of colonists. Rather than directly controlling the colonists, you place blueprints for buildings, mark trees for cutting, and animals for hunting. NPCs will then decide what to do automatically, based on their skills and priorities.

I’ve made two games recently with similar mechanics. The first was Ruben’s Virtual World Project (RVWP), a hybrid basebuilder/topdown shooter. The second was Tin Mining, a mining sim created as an entry to Ludum Dare 48. Both of these games allowed placing building plans that NPC workers would then build out.

In this article, I will explain how I implemented the NPC AIs, and the problems I faced.

Read more of "Creating worker NPCs using behavior trees"

The cover of "Tin Mining - Ludum Dare 48 post-mortem"

Tin Mining - Ludum Dare 48 post-mortem

In April 2021, I participated in my first game jam, Ludum Dare 48. Ludum Dare is a popular online game jam; this event received over 3800 submissions. The theme was “Deeper and Deeper,” and I created a game where you manage a tin mine.

The year is 1790, and the Cornish tin industry is booming. You are a businessperson who has just secured investment to build a mine. The area is known to be rich in tin, which is in high demand.

Rather than controlling your workers directly, you drag out plans for tiles to be mined and built. The workers will mine tunnels and build where ordered. They will carry mined resources to the surface to be sold.

Read more of "Tin Mining - Ludum Dare 48 post-mortem"

The cover of "Extending sol3's implicit type conversion"

Extending sol3's implicit type conversion

Many APIs in my game push Vector3s to and from Lua. It’s such a common operation, that most of my functions used to look like this:

sol::table add(sol::table tPos) {
    Vector3f pos = TableToPos(tPos);

    // do something
    return PosToTable(pos);

One of the benefits of sol is that it is able to bind Lua arguments to C++ function arguments, converting types implicitly. Having to convert from a table to a vector ourselves is quite annoying. It would be much nicer to have sol do it for us. Luckily, sol allows you to customise how types are retrieved and pushed to Lua using Customisation Points.

When trying to convert a type from Lua to C++, sol will call certain templated functions. We will be customisating sol’s behaviour using a technique called template specialization, which allows us to specialise a specific instance of the templated functions and structs. By the end of this article, we’ll be able to use Vector3 directly when using sol, allowing the above code to be turned into this:

Vector3f add(Vector3f pos) {
    // do something

    return pos;

Read more of "Extending sol3's implicit type conversion"

The cover of "A Comparison of SFML GUI Libraries: TGUI vs SFGUI vs ImGui"

A Comparison of SFML GUI Libraries: TGUI vs SFGUI vs ImGui

SFML is an excellent library that can be used to create 2D games and similar applications in C++. It’s an abstraction over OpenGL and various system APIs, presenting a consistent and easy-to-use interface.

Providing a Graphical User Interface (GUI / UI) API is out of scope for SFML. GUIs are complicated, and there’s no single good way to implement them. The S in SFML stands for Simple but GUI code rarely is.

There are many different options to choose from when making GUIs. This article is an in-depth comparison of the options for making GUIs in SFML, discussing their pros and cons.

Read more of "A Comparison of SFML GUI Libraries: TGUI vs SFGUI vs ImGui"

The cover of "RVWP: Multiplayer Topdown Sandbox Game in C++"

RVWP: Multiplayer Topdown Sandbox Game in C++

For the last two years, I have been working on a very ambitious game. The game is a top-down sandbox with multiplayer support. I’m aiming towards a city-based game, where players can wander around a procedurally generated city. One of the main reasons I started creating this game is to learn about multiplayer networking at a low level - client-side prediction, server-side reconcilliation, cheat preventation, and reducing the visual effect of latency.

Read more of "RVWP: Multiplayer Topdown Sandbox Game in C++"

How to emit a single particle using SFML's Thor Particle System

Usecase: shells dropping in sync with firing, fake bullets, etc

You must use a particle emitter to create particles, however this doesn’t mean it’s impossible to create single particles on command. You can create a particle emitter which simply adds particles from a queue to the system

Read more of "How to emit a single particle using SFML's Thor Particle System"

3D Projection

Hello 2015! Recently I have created an implementation of the 3D projection algorithm. It is just wireframe models. It works pretty well, except it doesn’t do frustum culling. You still see things that are behind you, but upside down.

The source code of this implementation is available under the WTFPL or CC0 licenses - you can choose which one you want to use. Use WASD to move, arrow keys to rotate, space to ascend and shift to descend.

Read more of "3D Projection"