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

Show Posts

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.


Messages - vinicius.ras

Pages: [1]
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!

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

Pages: [1]