Jump to content
  • Advertisement
ItsQuesoTime

Optimizing Ordered 2D TIlemap Rendering

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!