The C Roguelike Tutorial
Welcome to the C Roguelike Tutorial. These lessons will teach you how to write a basic roguelike using C11. The only library we will be using is BearLibTerminal, a fantastic library that will handle all our drawing on the screen. Everything else is up to us to implement.
This tutorial is a mostly direct port of the Python TCOD Roguelike tutorial, though obviously changed to accomodate the choice of language and using BearLibTerminal instead of libtcod for the pseudoconsole. Because we won’t have access to libtcod’s roguelike-specific APIs, this tutorial is a little more fleshed out in algorithmic complexity as we will, for example, have to implement our own FOV system instead of using libtcod’s.
Small portions of this tutorial are copied verbatim from the Python tutorial. All rights to these sections go to the original authors.
But I Heard That C Is A Dead Language
There are several reasons why I’ve chosen to port the tcod tutorial to C.
C is the lingua franca of systems programming. Yes, there are many other options, but C is still widely used in many domains. There is significant worth in learning C, and why not do so while making a simple game as well!
As far as I am aware, there is no port of the venerable TCOD Roguelike Tutorial to modern C.
To quote the opening paragraph of Ben Klemen’s 21st Century C, 2nd ed: C Is Punk Rock: C has only a handful of keywords and is a bit rough around the edges, and it rocks. You can do anything with it. Like the C, G, and D chords on a guitar, you can learn the basic mechanics quickly, and then spend the rest of your life getting better. The people who don’t get it fear its power and think it too edgy to be safe. By all rankings, it is consistently the most popular language that doesn’t have a corporation or foundation spending money to promote it. Also, the language is about 40 years old, which makes it middle-aged. It was written by a few guys basically working against management—the perfect punk rock origins.
But enough talk, let’s get coding!