I've implemented a tile-based RTS-style scrolling map with SFML (.NET binding), and would like to get some opinions on two options I can see.
Currently what I am doing is keeping a large collection of Sprites for the map, and each tile stores its terran type and index into the sprite collection. The sprites are stored in a Dictionary<TileType, Sprite>, where the keys are the various tile types (enum: Grass, Forest, Ocean, Desert etc ...), and against each key I store an array of all the sprites for that terrain type.
I have a custom camera object which tracks the in-view area, and can be scrolled around the map. Each render call, I get the tiles that are in view according to the camera, and simply loop through them all, find the appropriate sprite in the collection, set its position and draw the sprite.
This works fine, and I get a solid frame rate (80-100 FPS) with 1200+ tiles on screen and several layers on top with complex alpha blending for transitions etc.
The second option I can see (which I have read a bit about) is to store the map data in vertex arrays, and to use the built-in SFML View object to handle scrolling. I'm not too sure how different this method would be, it seems to be pretty much the same approach with slightly different data structures.
I'm still a bit of a beginner with SFML, and most of my previous work has been with SDL Surfaces which are pretty much the same as the Sprite approach I have taken with SFML. Any thoughts, opinions or advice on this is welcome
archanianMember Since 27 Jul 2012
Offline Last Active Jul 12 2013 04:49 AM
- Group Members
- Active Posts 19
- Profile Views 1,668
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown