Playdate

The beginning of the journey

Hello everyone,

I'm excited to share with you my journey of learning how to develop for the Playdate console¹, a handheld gaming device with a crank² that offers a unique way of playing games.

One of the things I wanted to learn was how to load a tile map in the console, which is a way of creating levels and environments using small images called tiles. Tile maps are commonly used in 2D games, especially retro-style ones.

There are different tools and formats for creating and exporting tile maps, but I decided to use Tiled⁴, a free and open source editor that supports many features and formats. Tiled can export maps as JSON files, which can be easily parsed by Lua, the programming language used by Playdate.

To load a map from Tiled, I followed this tutorial⁴ on the Playdate Developer Forum³, which explains how to create a class that can read a JSON file and draw it on the screen using an image table. An image table is a collection of images that can be referenced by an index number.

Here is some code that shows how to use the class:



This code works well for orthogonal maps (with right angles), but it can also be adapted for isometric maps (with diagonal angles) by changing how the tiles are drawn.

I hope this blog post was helpful for anyone who wants to learn how to load tile maps in Playdate. I'm still learning myself, so feel free to share your feedback and suggestions in the comments. Thanks for reading!

Sources: 

(1) Playdate. https://play.date/ Accessed 3/5/2023.
(2) Playdate (console) - Wikipedia. https://en.wikipedia.org/wiki/Playdate_(console) Accessed 3/5/2023.
(3) Loading maps from the Tiled editor - Playdate Developer Forum. https://devforum.play.date/t/loading-maps-from-the-tiled-editor/4862 Accessed 3/5/2023.
(4) Playdate - reddit. https://www.reddit.com/r/PlaydateConsole/ Accessed 3/5/2023.
(5) Has anyone posted a good tutorial for tilemaps? - Playdate Developer Forum. https://devforum.play.date/t/has-anyone-posted-a-good-tutorial-for-tilemaps/4529 Accessed 3/5/2023.
(6) GitHub - NicMagnier/PlaydateLDtkImporter: Load tilemaps created with .... https://github.com/NicMagnier/PlaydateLDtkImporter Accessed 3/5/2023.

Pitsu March 5, 2023
Share this post
Our blogs
Archive
Sign in to leave a comment