2D Tile Map Rendering (C++ w/ SFML)

Started by
3 comments, last by CPPapprentice 6 years ago

Hi Forum,

in terms of rendering a tiled game level, lets say the level is 3840x2208 pixels using 16x16 tiles. which method is recommended;

method 1- draw the whole level, store it in a texture-object, and only render whats in view, each frame.

method 2- on each frame, loop trough all tiles, and only draw and render it to the window if its in view.

 

are both of these methods valid? is there other ways? i know method 1 is memory intensive  but method 2 is processing heavy.

thanks in advance

Advertisement

Method 2 is not processing-heavy in any real sense of the word. You don't need to perform complex geometry on each tile - their position alone is enough to tell you whether they are offscreen or not.

Method 2, but you want to avoid looping through all of the tiles every frame. Here is an example of how to do that: https://gamedev.stackexchange.com/questions/32140/effecient-tilemap-rendering

Also, you may want to look up quadtrees to help with spatial queries as well.

i guess method 2 it is, i have some ideas on how to minimize the tile looping each frame, thanks guys

This topic is closed to new replies.

Advertisement