Progress on my Tiled API

I am working towards importing and using raw JSON files from the "Tiled" editor, which supports animated tiles, layers, flipping tiles horizontally/vertically, multiple tilesets. Features the PlayDate API doesn't do (well you can do layers, just not as easily)

I've got most of the above working, including dirty rectangle, and the tweening system for tile animations, and character X/Y/alpha plugged into an event system so I can queue commands (ie: you'll be able to tell a character to move north, north, east, wait till done, then tween alpha from 100% to 0%)

the main problem is Lua does not like the insane file format Tiled uses where it merges 6 datapoints into a single large number. So most of the blank parts of the map are tiles that are supposed to be flipped horizontally/vertically.

It does make minor changes to Tiled's data:
Tiled's properties are merged into the map's/tileset's data, and so is the class (noautoplay name=test becomes [noautoplay] = true and [name] = "test") and the layer will only be drawn if it has a [z] property to define it's z-index

Characters exist on a given layer, and they're sorted by Y then X. And any tile row on the same layer is drawn after the characters in the previous row, which is how the elevator door shows above the character on it's same layer. They have states (Mark S is currently in "standing" state) and when finished the "walking" state they'll automatically return to the default state (the first one declared)

It will use lua files for it's scripting, unlike Pulp which has it's own scripting language. Which saves me a ton of work.



I've started something similar, although nowhere near as advanced as what you're describing above, using the sample code in the SDK as a starting point.

Can't wait to try yours too.

I'm back from my vacation

So for the collision detection I had intended to use classes (ie: wall, north, south, east, west) to indicate if a tile was not walkable from a specific side, but I caved and used Tiled's collision system (but just rectangles) as I want to use it's editors for as much as possible. Not that this GIF shows that yet as I don't have the movement system implemented


1 Like

I got Tiled-perfect collision detection working!
It'd be a bit more impressive if the debug draw stuff showed in the GIF cause it shows the rectangles
I skipped using PlayDate's collision detection cause I felt I could do it faster, as it's only loading the collision rectangles directly in the path of the character, on the same layer. I still use geometry.fast_intersection though.

Now I need to add the event handler and camera tracking. All the hard stuff is done!


1 Like

Camera tracking and event handler is in! Though it was easy since Playdate's API lets you dynamically load Lua files (have I mentioned how much I enjoy Lua?)
My Space Invaders clone used a similar system just so I could get the hang of it. I can also now declare dirty rectangles manually (for the toast popup) and set which sides of the map you can walk off of


1 Like

Please keep doing what you're doing, I can't wait to see where this ends up!

(P.S. Nice job on the tile-perfect collision detection!)


Very excited to use this down the road!

1 Like

Have you tried this on a device or just in the simulator? We don't support runtime Lua compilation on the hardware. See this comment:

Not this part as I don't have one yet (group 5 :frowning: ) but I was told where the file is a pdz file, and filename omits .pdz, works

Ah good, .pdz files are precompiled so that should work fine.

1 Like

You had me worried for a sec since I already used this in a game. Though it sold quite a bit so you'd think someone would have warned me if the first level didn't work.

I have to say I am thoroughly enjoying developing with Lua. It's so close to what I'm used to (Visual Basic 6 and Basic4Android's syntax, Javascript's typeless and functions are variables, and how JS handles arrays/objects) that the transitional period was like a week. Though I'd still like variable types but that's just me being OCD. I just can't wait to play my games on the hardware one day

thank you. It was harder than what I had planned (another dev here just used classes to define if the tile was walkable or not, I was going to go with something similar) but I really wanted to stick with the tools Tiled offered so I bit the bullet

1 Like

So I've been committing a cardinal sin of designing my maps in MS Paint and the newest map (not shown cause I was testing with a smaller one for time's sake) is huge, and figured it'd probably take me less time automating converting it to a tileset image+JSON and map file than it would for me to used Tiled and do it myself. Now this only makes 1 layer and 1 tileset, but it still saves a ton of work

Results in (screenshot of Tiled):
I just have to work out the error, my math is probably off by 1 somewhere (EDIT: It's now fixed)

I added:

  • it automatically inserts "-table-[tilewidth]-[tileheight]" into the filename before the extension
  • you can save as a simple JSON tilemap for the existing API without flip X/Y support (you have to uncheck Flip X/Y from the Sample menu first though)

I haven't decided how I'll release the API but this program will probably be handy and I'll release it for free.

Example JSON:


Tiled's collision editor is a pain so I decided to take care of that too. Though this will only result in simple, full-tile rectangles. But should still end up saving quite a lot of work

1 Like

My game has reached a playable state!