roguelike-tutorial

Roguelike Tutorial Revised ported to C

View on GitHub

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.

  1. 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!

  2. As far as I am aware, there is no port of the venerable TCOD Roguelike Tutorial to modern C.

  3. 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!

Table of Contents

00: Setting Up Our Environment

01: Back @ You

02: Scuba Diving

03: Go Forth And Dungeon

04: If You Build It, They Will Come

05: A Visit To The Optometrist

06: Making Our Dungeon Less Lonely

07: Sometimes When We Touch

08: I Need More Data

09: Potion Seller, I’m Going Into Battle

10: Fast Times at Hogwarts High

11: Saving The World

12: Deep Dank Dungeons

13: Parry This You Filthy Casual

14: Top Gear

Contact Me

If you have any problems or issues feel free to send me an email or hit me up on keybase

See any errors? Shoot me an email or preferably clone the repo and submit a patch. do not know how to use email and git? Check out this awesome tutorial