1
Graphics / Weird lines being drawn between map tiles
« on: April 26, 2011, 11:14:16 pm »
That worked for me!
Thank you for the quick reply!
Thank you for the quick reply!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
// 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;