Is it possible to see source code for things like tilemap and sprite?

Hello, I know that if you go into the PlaydateSDK/CoreLibs there's some files you can look at but there's some stuff I cant find. I'm not seeing anything for the tilemap. And even in the sprite file there's no definition of the function :add(). Are these things that we can look at or are they locked for developers? Any information on how to view and better understand the playdate stuff would be helpful.

CoreLibs is a collection of Lua code built on top of the base SDK, convenience code we've developed over the years that didn't belong in the system core--though sometimes we do move code from CoreLibs to a native implementation to improve performance. A lot of the sprite code used to live in CoreLibs and now is implemented inside the Playdate runtime in C. The CoreLibs source is available in the SDK because it's useful to be able to read it and customize it, but also because that's just how Lua works. I guess we could have come up with a compiled bytecode library format and distributed it in that format instead, but that sounds like a lot of work and it wouldn't be as useful.

The base SDK (that is, all the functions listed in Inside Playdate that don't say they're in CoreLibs) is closed source, though I'm always happy to answer questions about implementation details (e.g. acceleratedChange in C SDK - #4 by dave).

1 Like

Thanks for the reply! I have been experimenting with different options for making animated tiles in Lua. For consistency I try to work with a 15x10 grid of 32px tiles so it covers the whole screen and a little extra. I also update every tile every frame more for stress testing than actual implementation for now.

I'm trying to improve performance right now since there could be scenes with lots of water tiles etc. that have close to the whole screen animating at once.

The fastest I've found so far is having a 150 long array always in memory and looping through to set values in the array and then after that calling tilemap:setTiles again using that array.

Since for now it looks like my options are using tilemaps this way or writing something more custom in C I was curious what tilemaps are actually doing under the hood and why they are so much faster than drawing each tile with image:draw. Any other tips on how to squeeze the most out of tilemaps or a point in the right direction for implementing my own version in C would be super helpful.