🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Optimizing Ordered 2D TIlemap Rendering

Started by
2 comments, last by ItsQuesoTime 4 years, 9 months ago

Hello -

I'm currently working on a 2D tile-based game, and I have a few questions about optimizing my rendering process.

 

First, is that my scrolling is quite slow. I have a very large map, consisting of more than 5000 tiles rendered at a time. Right now, I have a two dimensional array that stores all of my tile data, and to scroll I erase the tiles and redraw them in their new positions. Is this a good way of doing it, and if not, how could I improve this? Is there a way different than simply removing and re-adding tiles?

 

Second, is that I'm planning on adding tiles with sections that go outside their designated spaces. Meaning, I basically want certain tiles to have an overhang of sorts over other tiles. To do this, I know that I'm going to need to either modify the drawing order (which goes through each row of tiles, one at a time from the top left corner, drawing them), or by adding a second tilemap altogether that renders over the first. How should I go about doing this?

 

Thanks for any help. My implementations work, but are far from ideal.

Advertisement
36 minutes ago, ItsQuesoTime said:

First, is that my scrolling is quite slow. I have a very large map, consisting of more than 5000 tiles rendered at a time.

Can the player see all 5000 tiles at one time? If not you don't want to render out anything the user cannot see. When I've worked on such games I only cycle through my 2D array to draw out what can be seen by using an offset for x and y in relation to the player's position, and how much the camera is supposed to show.

Programmer and 3D Artist

5 hours ago, Rutin said:

Can the player see all 5000 tiles at one time? If not you don't want to render out anything the user cannot see. When I've worked on such games I only cycle through my 2D array to draw out what can be seen by using an offset for x and y in relation to the player's position, and how much the camera is supposed to show.

On a very high resolution screen, what is actually visible would be more around 2000 tiles. I was planning on having the world be chunked, where entire chunks are loaded, including the parts outside of the screen. You're right though, that it would definitely make things faster to only update the tiles in the view. My main issue though is making the process of loading certain tiles first more efficient, and how that would relate to the scrolling animation aspect of it.

This topic is closed to new replies.

Advertisement