The first part was just to fill the tilemap with something. Ideally I’d just draw an image and load that but that’s another can of worms.
So anyways I just use the equation for a sine wave to define the terrain:
y >= y0 + amplitude*sin(frequency*x +x0)
x0 and y0 just adjust where the sine wave is.
I use >= because I want everything below the sine wave to be filled.
So you could fill the tilemap by looking at all the tile locations, plugging x and y of the tile into that formula and if it’s true drawing that tile.
It could look like this:
For “x” from 0 to tilemap.width-1
For “y” from 0 to tilemap.height-1
Compare: loopindex(“y”)>=y0+amplitude*sin(x0+loopindex(“x”)*frequency)
— set tile at (loopindex(“x”), loopindex(“y”)) to 1
Erasing is basically the same. Look at all the tiles and measure their distance to the center of the circle. If the distance is less than the radius, erase that tile.
Now it’s slow to loop over all the tiles. But we don’t have to. With a circle we can look at the box of them a radius away from the circle.
We can do it faster by utilizing the “erase range” action instead of erasing each individually.
So we can loop x from -radius to positive radius.
And we can calculate the y position of the top half of the circle at that x. The bottom half y is basically flipped.
Sorry. I’m probably not helping at all. I’ve run out of time.
Hopefully it got the gist of it out there. The rest was just trickery to do less so it’s faster.