Hello guys,
I am making a game where I must use some tiles to construct the scene. When I load my map, I load the tiles and calculate the position of each of them.
But the boundaries of the tiles are being drawn in a weird way, as if the tiles were mixing with each other, like if they were blending.
I've made a simple test, and here's the code for my main function:
// Load tile image (a fully gray image, 256x256 pixels )
sf::Image tileImg;
tileImg.LoadFromFile( "gray.png" );
// Create some sprites to use the loaded image
const int imgWidth = tileImg.GetWidth(); // retrieve the width of the image, in pixels
std::vector<sf::Sprite> vecSprites;
for ( int s = 0; s < 4; s++ )
{
// Create the sprite, and retrieve a reference to it
vecSprites.push_back( sf::Sprite() );
sf::Sprite &spr = vecSprites.back();
// Position the sprites side-by-side, and make them use the same (gray) image
spr.SetPosition( s * imgWidth, 0 );
spr.SetImage( tileImg );
}
// Create the main rendering window, start game loop
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear the screen (fill it with black color)
App.Clear();
// Draw sprites
for ( size_t s = 0; s < vecSprites.size(); s++ )
App.Draw( vecSprites[s] );
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
In this test, I use an image which is 256x256 pixels, and it is completely gray. You can see the result at this screenshot:
http://img811.imageshack.us/i/sshot1wa.png/As you can see from my screenshot, there are some lines being drawn between the tiles. The tiles, as I've wrote the code, should appear like a single, big, gray rectangle, and the user should not be able to see these lines which separate the tiles.
I've also tried to set the blending mode to sf::Blend::None for all the sprites, without success.
Am I doing something wrong? How can I correct this problem?
Thanks!