The Quail's Nest
March 07, 2024
The Crypt: Candle
This is a project from 2017. I was enjoying ASCII-based roguelikes at the time, and I wanted to try making my own, ideally one that could be played fully inside a terminal. To do that, I would need a library for text-based output to a terminal.
I decided to use the Java Lanterna library. There was (and still is) an existing Clojure wrapper for it, but I had a lot of trouble using it because I didn’t understand the underlying abstractions of the Java library it was built on. So I decided to write my own wrapper, as a way of learning how the underlying Java library worked. This is that project.
A quick note about the project name, and why it doesn’t match the GitHub repo: It was originally called “Candle”, and that was the name at this stage of the project that I’m showing you. About six months later I did some updates, and changed the name to “Candlelight”.
As far as the code goes, it’s not too bad. It truly is just a thin wrapper over Lanterna, so there wasn’t much to mess up.
I must have used some kind of basic template for the project structure: there’s some boilerplate with unedited ‘FIXME’ messages sprinkled around, and a useless core.clj file.
Let’s take a look at the README. It’s actually a decent walkthrough of how to use the library, but there are a few problems:
Usage
In your project.clj dependancies:
[candle "0.1.2-SNAPSHOT"]
That’s not right – the version should be “0.1.3-SNAPSHOT”. This must be from when I first wrote the README, and then never got updated as development continued. And I don’t know why I was using “snapshot” in my version numbers, probably because I saw other projects using it.
Also “dependancies”.
The rest of the tutorial is in a single code block, with the instructions as comments in the code. I think I did this so you could just copy the whole tutorial into a file, and execute each line in a REPL as you follow along. But it looks kind of strange in the README markdown. I think it would be better as actual markdown text and code blocks, plus a separate tutorial file that could be run in a REPL.
A bit later on we have this:
;; scr/write! also takes optional foreground and background colors (scr/write! screen 0 0 "A second hello." :fg (u/rgb 55 255 100) :bg (u/ansi-color :yellow)) (scr/refresh! screen)
It seems ok, showcasing the two different ways of defining colors. But if you actually run it you’ll get this:
That’s a disturbing color combination. Don’t know what I was thinking with that one.
At least the all the code works, as far as I’ve tested anyway.
Lastly, we have the license at the bottom:
License
Copyright © 2017 FIXME
Guess I didn’t bother filling that in. Oops.
You can check out the whole project as it was then here.