Calling Tilemap functions from C code - 2.6.2 SDK?

Not sure if I'm being dense but I've searched the forum and Inside C page and can't seem to find an answer.

Tilemap functionality is built into the Lua SDK, and I can see various symbols in PlaydateSimulator.debug that suggest the Tilemap support is implemented in a C library:

00000000015a7c40 b gfxtilemaplib
000000000040fee0 t pc_tilemap_collect
000000000040f9a0 t _pc_tilemap_draw
000000000040f780 t pc_tilemap_draw
000000000040f990 t _pc_tilemap_drawWithoutOffset
000000000040f5e0 t pc_tilemap_getCollisionRects
000000000040fa40 t pc_tilemap_getPixelSize

But there doesn't seem to be a corresponding C header file for the function signatures? Am I missing something obvious? Are we supposed to be able to call the Tilemap SDK functionality from C?

Surely people are using the Tilemaps from C?

1 Like

The pc_ symbols are just the Lua_CFunction implementations of the Lua API -- there's a ton of stuff in the Lua API but not the C API.

1 Like

Ah, so they're not in Corelibs either, I did see other forum folks asking about this in the past. Thanks for the info!

Time to code a C tilemap then. Probably easy to get something going since there's already Tiled C map loader implementation with hooks. I was avoiding this because I didn't want to re-invent the wheel (gets out wheel-reinventing kit).

1 Like

I've got that in for 2.7. I guess I avoided adding it in the past because it's a pretty simple wheel that's easy to reinvent, and I figured anyone using tile maps in C would probably want to add their own features. The only thing LCDTileMap does that isn't completely obvious is it has update tracking so that if you set it on a sprite (nb I also added pd->sprite->setTilemap()) it only redraws the cells that have changed, not the entire sprite.

But for the most part it was just adding API entry points for the existing implementation. Most of the real work was making a demo and adding the documentation. Aha, that's why I've been avoiding this.

1 Like

Ahhh I appreciate it @dave thank you sir. It is an easy wheel to reinvent I suppose, but I still appreciate it!

1 Like