I have a full-time job as a software engineer, but let’s forget about that for a while. I’ve been told I need to get some hobbies. This could mean travel, sports, or developing a game engine from scratch using the most notoriously difficult graphics API in existence. Let us explore the folly of the latter choice.
Why?
If you want to develop a video game, you’re generally told to use an engine like Unity or Godot. They’re free for personal use, very easy to get into, have a massive community backing them up, and abstract away the painful process of dealing with the fickle GPU yourself.
So why go through the trouble of rolling our own engine? I give you the following reasons:
Performance: As you’ll find, the game which we are going to develop will contain a massive number of entities and quite a lot of computation - much of which we hope to parallelize on the GPU. Utilizing a low-level API will allow us to optimize our routines on a level simply not allowed by highly abstracted game engines.
Utility: I hope that by delving into the absolute basics of everything from physics to rendering to UI will allow us to innovate to a greater degree by examining certain core assumptions and how they relate to our specific game.
Knowledge: This undertaking will be greatly instructive not only in the field of graphical programming, but also in the field of developing high-performance, close-to-metal software, which is greatly useful1 and has a high skill ceiling.
Vanity: Game engines like Unity are (infamously?) easy to learn. Some people I personally dislike2 are also into game development, so it’s imperative that I avoid any association. To this end I need to demonstrate that I am cool and hardcore so we’re going to do this in Vulkan and die.
LinkedIn: Self-explanatory.
I think this is good enough.
What?
This is all well and good, but we haven’t mentioned what we will develop yet.
We are making a 4-player free-for-all 2D RTS3 where each player summons creatures, builds structures and fights with the goal of being the first player to dig to the bottom of the map. Players and their minions will fight, mine, build infrastructure, disrupt each other’s supply lines, and interact with the existing underground world to get ahead. Each game will last ~30 minutes.
We will flesh out this concept in future posts, but let’s set some guiding principles for now:
Avoid the late-game: In strategy games, the most boring part is usually the late-game, where the player is essentially reduced to being an accountant for the “system” that they’ve created. We hope to avoid this by forcing the players to continually dig downward, thus making sure their surroundings are always new and underdeveloped.
Avoid defensive posturing: The structure of the existing underground world - meaning caves and such - should be designed to funnel players toward each other, making their optimal strategy more combat-oriented.
Take nothing for granted: Resources won’t exist solely in a magical counter on the screen or some hand-waved global “inventory”. Every single resource will exist as a tangible physical entity which needs to be retrieved, hauled, and delivered to its destination. This will increase the complexity of the game and create fun mechanics around supply lines and their disruption.
Use the natural world: The underground is an exciting place filled with not just resources, but existing flora and fauna, as well as dangers — earthquakes, floods, volcanic activity — will be both natural and man-made, and heavily impact game-play. Introducing random natural phenomena will also hopefully reduce the snowball advantage of the player who is currently ahead.
Vision: In the spirit of taking nothing for granted, we will have a heavy focus on the fog of war. Half the battle will be just knowing where the enemy is, which will be accomplished with the help of guard, light recon and blocking units, as well using the natural world — for instance monitoring the seismic activity caused by the movements of other players.
I have no prior experience with game development aside from small personal projects, so this is all probably overly ambitious and directionless for now, but we’re all here to learn.
One small point - what are we going to call this game? I don’t know, but since we’re digging, I am going to call it Dig until I think of something better.
How?
With Vulkan of course! This series will presuppose an understanding of the absolute basics of computer graphics - meaning everything you need to draw a triangle and a sampled texture in Vulkan.
If you’ve not done this, follow along the excellent (and perhaps only) Vulkan tutorial at https://vulkan-tutorial.com/ - and good luck!
In fact, our starting point will be roughly the code you should get after finishing the Texture Mapping section of the linked tutorial. Running the code associated with this chapter should give you this lovely rendering of a tilted, spinning cat, rendered at a blazing rate of 4000+ FPS
Seems easy, right? You might be surprised to learn that it took 1197 lines of code to get to this point.
Like I said, if you haven’t followed the tutorial yet you’re in for a fun ride.
The point is that we start off where the tutorial leaves you, so the code is intentionally4 written as a ridiculously flawed single-file monstrosity aptly called main.cpp
, and part of our job in the next few chapters will be organizing and greatly improving upon it.
Moving forward
I think that’s enough of an introduction. The end scope of this project is something that’s — for now — beyond my skill level, so please don’t assume any of the code is optimal, and take my statements with a grain of salt.
We will make mistakes together, and hopefully with your feedback end up creating something fun.
The code is available at the repository over at https://github.com/calasanmarko/dig , and every chapter will have the corresponding branch linked at the bottom.
See you soon!
The code for this chapter is available at: https://github.com/calasanmarko/dig/tree/chapter-1
GPUs are also becoming increasingly important in the field of general computation, which is another added benefit.
I try not to harbor any hate in my heart.
I don’t actually know what these terms mean.
lol