Hello,
So I'm messing around with VertexArray for displaying tiles. I've checked out the tutorial example here on the SFML site. I'm trying to figure out how I can scale the tile bigger (
for learning and clarity purposes). I can do this just by displaying 1 tile, but when the for loop is involved, I'm a bit
confused?
The tiles are 32x32, and the tile sheet provided in the example.
sf::Vector2i tileSize{32,32};
float Scale = 128;
...
for loop(... i < 20 ...)
for loop (... j < 10...)
{
// define it as a rectangle, located at (10, 10) and with size 100x100
quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.x);
quad[1].position = sf::Vector2f((i + 1) * tileSize.x [b]+ Scale[/b], j * tileSize.y);
quad[2].position = sf::Vector2f((i + 1) * tileSize.x [b]+ Scale[/b], (j + 1) * tileSize.y [b] + Scale[/b]);
quad[3].position = sf::Vector2f(i* tileSize.x, (j+1)*tileSize.y [b]+ scale[/b]);
...
}
I know this must be a
simple formula adjustment. I haven't worked with anything like this yet, but I know it's similar to placing a rectangle in OpenGL.
Also, I believe I read something about using a VertexArray for your tilemap improves speed. Something about how it can be turned into one big image? This was before I got into looking at VertexArray (
looked too complicated) and I was trying to figure out the best camera culling methods (
not sure of the correct term).
Does anyone perhaps have an example of a big map using VertexArray or perhaps even comparing the differences of using a Sprite for each tile? And even more ideal example would be with culling?Hope that makes sense, and
have a great day.