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

Author Topic: [solved]Tiles are showing black lines at the borders (1.6)  (Read 13237 times)

0 Members and 1 Guest are viewing this topic.

jd80127

  • Newbie
  • *
  • Posts: 2
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« on: April 09, 2010, 12:52:25 am »
Hi everyone. Thanks for this great site!

Anyways I am having a problem where black lines are drawn around my tiles. Here's an example with a white 64x64 tile:



Here's the relevant segments of my code:
Code: [Select]

    float loopVarX = 0;
    float loopVarY = 0;
    int forX, forY;

    // Create the main window
    sf::RenderWindow App(sf::VideoMode(1600, 1200), "MY GAME");

    // SET 2 dimensional array of sprites all to the grass image
    Sprite Sprite1[25][18];  

    for ( int a = 0; a<25; a++)
        for (int b = 0; b<18 ; b++)
        {
            Sprite1[a][b].SetImage(CammyCreature.Grass);
        }


        // Draw the grass
        for (forX = 0; forX <25; forX++)            // DRAW 25 tiles horizontally
        {

            for (forY = 0; forY <18; forY++) // DRAW 18 tiles vertically
            {
                App.Draw(Sprite1[forX][forY]);          // Draws the grass at the location specified by the variables
                loopVarY = (forY * 64);                 // Configures the Y Coordinate to be images new location
                Sprite1[forX][forY].SetY(loopVarY);     // Sets the next Y Coordinate location of the next image to be drawn
                Sprite1[forX][forY].SetX(loopVarX);     // Sets the next Y Coordinate location of the next image to be drawn

            }

            loopVarX = (forX * 64);
           
        }



Anyone have any ideas? I just upgraded from 1.5 to 1.6. I could be wrong but I thought that it was working with 1.5. I only noticed this with the upgrade to 1.6. Though its definitely possible that it could have been there the whole time. Could this be the 1.6 bug that other people are having problems with?

I could definitely post the whole program (123 lines of code) if you guys think that would help.

Thanks so much

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #1 on: April 09, 2010, 01:33:23 am »
Are you setting SetSmooth(false) on the image before loading it into the sprite?  I've been using 1.6 for the tile engine I've been working on and it works fine unless I forget to set that.

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #2 on: April 09, 2010, 02:02:43 am »
Just check that your tiles origin and center are in round coordinates. If the problem persist, try disabling the smoothing like Breakman said before.

jd80127

  • Newbie
  • *
  • Posts: 2
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #3 on: April 09, 2010, 02:59:54 am »
Thanks guys, very helpful forum.

SetSmooth(false) did the trick.

Bernd

  • Newbie
  • *
  • Posts: 11
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #4 on: May 30, 2010, 05:56:51 pm »
Thanks...had the same problem and it was driving me nuts :-)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #5 on: June 15, 2010, 08:13:32 am »
It does work, but you probably have another problem.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #6 on: June 15, 2010, 09:45:34 am »
And can you post a screenshot of what you get in your SFML application?
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #7 on: June 16, 2010, 03:15:29 am »
Well hopefully Laurent knows what's wrong.

I can't really help unless you tell me which SFMLv you are using and post the full code.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #8 on: June 16, 2010, 05:48:31 am »
Well after taking a glance it looks like your position is off since there is 0,0 start position yet your multiplying it times 32 so it's creating a space.

If that doesn't solve it you can test your tiles to see if there is a hole by setting your clear color to red:  

Engine.Screen.Clear(sf::Color(255,0,0));


UPDATE:I had some free time to test your code with tTile.Sprite.SetPosition( x * 31, y * 31 ); and I was right it works now.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #9 on: June 16, 2010, 06:29:54 am »
Quote from: "MarthKoopa"
The calculations for the tile positions are correct.  I tested it with a 32x32 image of one of my tiles, and it works fine.  But I hate having every tile in its own image, it's annoying to code with.

If I put the SubRect to (0, 0, 32, 32), it'll look fine for a while, but when you start moving, parts of the tiles below and to the right of the topleft tile in the tileset image show up


Well it's hard to tell. On the demo you sent me it's fixed

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #10 on: June 16, 2010, 06:50:37 am »
I did this to test and it worked seamlessly:

Code: [Select]

  for (float x = 0; x < get_width+1; x++){
            for (float y = 0; y < get_height+1; y++){

  tTile.zSprite.SetPosition(x * 256, y * 128);

                tTile.zSprite.SetImage   ( Engine.TileSet );
                tTile.zSprite.SetSubRect ( IntRect ( 0, 0, 256, 128 ) ) ;


Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #11 on: June 16, 2010, 07:09:51 am »
Quote from: "MarthKoopa"
But your SubRect there is just grabbing the entire image file, defeating the whole purpose.


That's just to test it. You can't see well with the brick because both sides have the same color. If you make it 32x32 it should work.

If you don't think it works try 64x64, take a screenshot and drop the source image on it photoshop it lines up correctly.

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #12 on: June 17, 2010, 11:31:00 am »
So, I suppose you corrected this:
Quote from: "MarthKoopa"

Code: [Select]

tTile.Sprite.SetSubRect ( IntRect ( 0, 0, 31, 31 ) ) ;


to this
Code: [Select]

tTile.Sprite.SetSubRect ( IntRect ( 0, 0, 32, 32 ) ) ;

I tested with the code you initially posted, with the correct rect, and it worked fine. What's wrong now?
Pluma - Plug-in Management Framework

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #13 on: June 17, 2010, 10:51:14 pm »
Yes,
It's a well known "bug". In order to have pixel art tiles you have to use Smooth to false, but when moving them around the screen they are using floating numbers thus, something is wrong with the drawing. Laurent knows that issue but "it's not a bug" as far as I know, it's just a tricky unsolvable problem...
Mindiell
----

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[solved]Tiles are showing black lines at the borders (1.6)
« Reply #14 on: June 18, 2010, 08:51:39 pm »
Whatever the case I recommend using sfml2 if you can because it changes the rect code and fixes the smooth problem as well as other things.