I spent some time over the past few weeks making a simple autotiling helper that uses a Tilemap for drawing. I decided to share it on GitHub so others could use it if they wanted: GitHub - GammaGames/Playdate-Autotile: A simple autotile helper class for the Playdate, written in Lua
A simple breakdown of how you could set it to some random noise:
import "autotile"
math.randomseed(playdate.getSecondsSinceEpoch())
local at = Autotile("monochrome-tilemap", width, height)
at:moveTo(200, 120)
-- Generate some noise
local noises = gfx.perlinArray(
at.columns * at.rows,
math.random(), 1,
math.random(), 1,
0, 0,
0,
1,
0.5
)
-- Set each cell to SOLID or EMPTY
at:setCallback(
noises, at.columns,
function(val)
if val > 0.5 then
return STATE.SOLID
else
return STATE.EMPTY
end
end
)