💾 Archived View for avfig.com › gemlog › tiled-maps-in-common-lisp.gmi captured on 2022-04-29 at 11:24:39. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

Tiled Maps in Common Lisp

By Jeremiah Stoddard on January 22, 2022

I've been toying around with throwing together a tile-based CRPG in Common Lisp, sort of like Ultima (but with top-down dungeons) or the old NES game Dragon Warrior (now known as Dragon Quest). I initially intended to throw together a small map editor for a simple binary format map. I have done it before in other languages and figured it would be a relatively easy weekend project. In the end, I got the good folk at #lispgames to convince me to use the already-existing map editor Tiled.

I was well into writing my own parser for Tiled's .tmx file format when I decided that I was doing a poor job at reinventing the wheel. My parser was pretty limited to a map setup particular to my game, and it was not at all robust. It would ignore features not used by my game, but would likely crash and burn if something expected was missing, or something unexpected came up. So I decided to use cl-tiled, a Common Lisp library for parsing Tiled maps, for initial parsing the map files and then import the data provided by cl-tiled into my game's own data structures.

cl-tiled is a useful tool, but I found a few bugs that could pose problems. One involved a mistake in the definition of a slot type, which prevented the library from functioning in Clozure Common Lisp (CCL checks slot types while SBCL does not by default). Another caused problems reading maps with object layers, and yet another prevented reading an object's properties from working. Since the project isn't terribly active, I have placed fixes for now in a forked Github repository:

Fork of cl-tiled (web/Github)

I hope these or similar fixes will be incorporated into cl-tiled at some point. For now, if by strange coincidence you, too, are working on a tile-based game in Common Lisp, maybe you will find the "fixed" version of cl-tiled useful.

Back to Jeremiah's Gemlog