Hi everybody,
I'm learning SFML and trying to build a small application which uses a 2d tile map; I looked around about some question but couldn't be able to find a complete response, so I decided to ask directly on the forum.
Thanx in advance to everybody who will answer!
Let's say I have a big matrix representing a map, e.g. 1000 * 1000 tiles,
and want to implement a scrolling view over this map.
The scrolling of the view goes one tile at a time, and doesn't have to be realtime, I don't need smooth scrolling pixel by pixel, since the application is turn based (but smooth scrolling is not forbidden...).
Every element of the matrix contains the tile code, so I will build a table mapping every tile code to the corresponding graphic element.
I could load a single image for every tile code (every type of tile), or could load a big image containing all the types of tiles and then addressing to its subrectangles for every code I need.
So far, it seems to me the right "graphic element " is the sprite, but I guess I have two different solutions
- should I build a matrix of sprites just as big as the viewport (let's say 25 * 25) and recalculate the sprites every time I change the coordinates? I'm trying this solution, but it seems to me that continuosly changing the image linked to the sprites is not really good.
- should I build a sprite for every tile, and then use a view? View seem the obvious solution, but I'm wandering if it's good to build a 1000*1000 matrix of sprites.
Regards
Marco