SFML community forums
Help => General => Topic started by: The Terminator on October 19, 2012, 07:52:00 pm
-
I'm creating some tilemap support for my engine, and I can't really decide which two ways to go about it. Here's two ways I thought of: (P.S. I plan to load the tilemap from an external file such as a .txt)
1:
Each tilemap would be represented as a child class that would be derived from a base class called TileMap. To draw this tilemap when the character does something such as reaches the edge of the map, you would pass a reference to the object of the child class and it would draw that specific class. A camera would not be needed as the certain tilemap would be seen as a whole on the screen.
2:
Have 1 huge tilemap that periodically draws itself when the character moves in a certain direction. Once the character has reached the edge, it will collide and stop. A camera will be needed because the tilemap would need to scroll in the direction that the character is moving. There would only be one class called TileMap with methods such as void drawMap(), etc.
It would be helpful for some advice to pursue this task. Thanks in advance!
-
I wouldn't do one or the other... ;)
Instead I'd use a sf::VertexArray which will represent the whole tilemap, I then only render what is actually displayed on the screen and make use of sf::View for scrolling.
But I can't give you any more hints on that topic since I haven't implemented a tilemap on my own. ;)
-
There's an example on the wiki that works for square, static tiles.