SFML community forums
Help => Graphics => Topic started by: Makuto on December 08, 2011, 04:23:41 am
-
Hi, I just finished coding a simple tile map outputting system and was pondering over the problem of clipping the sprites at the top and left edges of the window. I was planning on having smooth(ish) scrolling where the tiles move over as little as 1 pixel even though they are 64X64 or 32X32. I am aware that if the origin is negative the image isn't displayed. What would the best way be to handle the clipping of the tiles? Would sf::View work well?
EDIT: Actually, I guess images ARE still displayed even if the origin is negative. I guess I don't really need to worry about the clipping anymore :)
-
As soon as you're moving a map, apparently what you want is a Camera implementation using sf::View.
What I'm doing at the moment, I draw tiles (32x32 pixels) in chunks of 50x50.
I always draw them at the same position, but I move the sf::View around when the player moves.
That way, it's fairly simple to keep track/render everything, AND, when I know a chunk is too far away to be drawn on the screen, I unload it :)