Using amethyst_tiles for 2D terrain

I’m currently prototyping with Amethyst for a top down 2D game. The goal is to have a large “map” with traditional square tiles for terrain. The larger map the better; in fact auto generating on the fly would be optimal but for now I prototype with a set size. The tiles are mapped to an underlying noise array that controls sprite selection, collision, etc.

I found the tile example and thought the Amethyst tile functionality would be a good base to start from, so I looked through the example and added some terrain using the RenderTiles2D plugin and a TileMap with MortonEncoder2D. It’s easy to work with and the sprite function in the Tile trait makes it easy to map a specific coordinate to the underlying noise array.

But the tile example uses a fairly small map, 48x48, and my map will have to be much larger. As I scale it up the drawing performance drops quite fast; even before I can cover the current window with tiles (1920x1080) my other “moving” sprites on top of the terrain starts drawing choppy.

So my question is: Is TileMap a good base for a project like this, and in that case why is the performance dropping so rapidly? Is it supposed to be used differently? Or should I just write custom systems for rendering the terrain?

I am using the RenderTiles2D plugin together with the RenderFlat2D plugin.

I couldn’t comment on TileMap specifically, but I have noticed that when run in debug mode, frame rate tends to drop quite quickly with Amethyst. However, if you then run in it release mode (cargo run --release) it has no problems running at 60fps.

1 Like

Yeah, you’re right. Running with optimizations makes a really big difference, didn’t think about that. Thanks!

1 Like

It’s not in the book, but there is a trait you can implement for culling: