Need some help with performance issue on dynamic tiled map #3007
Replies: 3 comments 9 replies
-
If you have performance problems with that type of game, yes, you are probably doing something wrong. If you could share the actual code that would be the easiest, but in the meantime, here is the general idea of what you should be doing and common pitfalls:
This is similar to what this example does: https://ebitengine.org/en/examples/tiles.html. This example is a bit more raw, but that's the general idea. For further performance tips, you might also be interested in https://ebitengine.org/en/documents/performancetips.html. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your advice. I just checked the tile example (https://ebitengine.org/en/examples/tiles.html). As I could understand, it has a small number of tiles. and all tiles can be spliced together in order to load them into mem an once. the Draw() function can pave the screen with sub image. I read some similar guides before. But with 1000*1000 tiles, I still cannot follow the way. I debugged into my code again. I made a small set of tiles cached in memory as *ebiten.Image, so all the io work were eliminated. the FPS went higher, but still not acceptable. I guess those 20x20 DrawImage calls is the key problem. the guide (https://ebitengine.org/en/documents/performancetips.html#Make_similar_draw_function_calls_successive) says:
I'll dig into it and have a try. |
Beta Was this translation helpful? Give feedback.
-
My chunk loading system that I posted on the Discord channel yesterday. I think there is a bug in your code. In the video 2000 tiles are drawn without dropping FPS, it can draw more tiles but there is no need. chunks.mov |
Beta Was this translation helpful? Give feedback.
-
Hi guys, many thanks to the simplest game engine I've ever seen.
I'm trying to made a game demo with ebiten these days, and I run into a serious performance issue. Need some help.
The game scene is 800x600 in pixels. it only displays a viewport of the map. the full map is a huge world, made of 1000x1000 tiles, while each tile has the size of 48x32. I cannot load them all into mem. so they are dynamically loaded in to mem while the player moves around.
Here's what I did: in each Draw(), I calculate those tiles need to be drawn (about 20 x20 tiles), load them into memory, and draw them
one by one to make the scene. I have a feeling that something is wrong... and yes, the FPS drops down to 5, or even lower.
Is there any better way of doing it?
Beta Was this translation helpful? Give feedback.
All reactions