Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird lines being drawn between map tiles  (Read 1658 times)

0 Members and 1 Guest are viewing this topic.

vinicius.ras

  • Newbie
  • *
  • Posts: 2
    • View Profile
Weird lines being drawn between map tiles
« on: April 26, 2011, 10:34:57 pm »
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:
Code: [Select]

// 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!

cooldog99

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • Perilous Game Studios
Weird lines being drawn between map tiles
« Reply #1 on: April 26, 2011, 10:44:55 pm »
Have you tried turning off smoothing?

MyImageName.SetSmooth(false);

vinicius.ras

  • Newbie
  • *
  • Posts: 2
    • View Profile
Weird lines being drawn between map tiles
« Reply #2 on: April 26, 2011, 11:14:16 pm »
That worked for me!
Thank you for the quick reply!

cooldog99

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • Perilous Game Studios
Weird lines being drawn between map tiles
« Reply #3 on: April 27, 2011, 12:09:44 am »
Quote from: "vinicius.ras"
That worked for me!
Thank you for the quick reply!


No problem man, think of it as my way of contributing back to this awesome forum ^_^

I'm always here if you need more too :D

 

anything