Making a dynamic jigsaw game

I’ve made jigsaw games with other tools before. The usual way I’ve done it was to generate the pieces and place them into texture atlas pages and then save those textures to disk between sessions of same puzzle. That’s not easily possible with Defold…

Shaders are another way but an issue is that batching breaks so if you have hundreds of small pieces then you have hundreds of draw calls.

Pre-generating puzzle pieces is possible also but that is a huge binary size waste and not dynamic.

Any ideas?

Hmm, maybe one big atlas with placeholder images for the jigsaw pieces (all equally sized). Load the jigsaw image into a buffer. Cut out the pieces somehow. Arrange them in a buffer of the same size as the atlas. Use resource.set_texture() to update the placeholder atlas?

1 Like

That’s a good idea! Would want to do the buffer work in a native extension most likely. Just need a template for each puzzle size / count.

Yes, that’s probably good for performance reasons. Not sure how to best approach the template and cutting out the pieces.

Is there a way to get UV data of textures at runtime?