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

Author Topic: Tilemap problem: rotated tile-sprite  (Read 1987 times)

0 Members and 1 Guest are viewing this topic.

dreadnought

  • Newbie
  • *
  • Posts: 8
    • View Profile
Tilemap problem: rotated tile-sprite
« on: March 01, 2012, 12:46:14 pm »
Hi there,
im currently trying to get my tilemap working.
mostly it works fine, but to reduce the number of
needed tiles i added the abillity to rotate a tile.
But when i actually do that i get some nasty black lines.
(See the pic i added)
Here is the code i use:
( Tilesize is 50)
Code: [Select]

MapTile.LoadFromFile("data/img/TileSet.png");
MapTile.SetSmooth(false);
maptile.SetImage(MapTile);
maptile.SetCenter(25,25);
mousetile.SetImage(MapTile);
mousetile.SetCenter(25,25);

...

// Draw Map-Tiles
for (int i = View::GetViewRect().Left/TileSize; i<View::GetViewRect().Right/TileSize && i<Game::GetMapWidth();i++)
{
for (int j = View::GetViewRect().Top/TileSize; j<View::GetViewRect().Bottom/TileSize && j<Game::GetMapHeight();j++)
{
maptile.SetPosition(i*TileSize+25,j*TileSize+25);
sf::IntRect SubRect;
if(Map[i][j]._tile==0)
{
emptytile.SetPosition(i*TileSize,j*TileSize);
renderWindow.Draw(emptytile);
}
if(Map[i][j]._tile==1)  
{
SubRect.Left=0;
SubRect.Top=0;
SubRect.Right=50;
SubRect.Bottom=50;
}
if(Map[i][j]._tile==2)
{
SubRect.Left=50;
SubRect.Top=0;
SubRect.Right=100;
SubRect.Bottom=50;
}
if(Map[i][j]._tile==3)
{
SubRect.Left=0;
SubRect.Top=50;
SubRect.Right=50;
SubRect.Bottom=100;
}
if(Map[i][j]._tile==4)
{
SubRect.Left=50;
SubRect.Top=50;
SubRect.Right=100;
SubRect.Bottom=100;
}
if(Map[i][j]._tile!=0)
{
maptile.SetSubRect(SubRect);
maptile.SetRotation(Map[i][j]._direction*90);
renderWindow.Draw(maptile);
}
}
}


can someone help me with this?


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tilemap problem: rotated tile-sprite
« Reply #1 on: March 01, 2012, 01:17:05 pm »
Have you tried to turn smoothing off (tilemap.SetSmooth(false))?
Laurent Gomila - SFML developer

dreadnought

  • Newbie
  • *
  • Posts: 8
    • View Profile
Tilemap problem: rotated tile-sprite
« Reply #2 on: March 01, 2012, 01:27:17 pm »
as you can see on line two of the code smoothing is allready set off

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tilemap problem: rotated tile-sprite
« Reply #3 on: March 01, 2012, 01:55:39 pm »
Sorry, I didn't see it.

You should try SFML 2. SFML 1.6 has some bugs and is not maintained anymore, you'll get more help (especially from me) with SFML 2.
Laurent Gomila - SFML developer

dreadnought

  • Newbie
  • *
  • Posts: 8
    • View Profile
Tilemap problem: rotated tile-sprite
« Reply #4 on: March 01, 2012, 02:37:25 pm »
i didnt changed to SFML 2.0 because there is no official release yet.
Im afraid i have to update my code to often when i use it before it is "ready"

But when you say "Hey fool, change to SFML 2.0! It is worth it!" i surely will update...
(and then bomb you with questions you have to answer ;)  )

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tilemap problem: rotated tile-sprite
« Reply #5 on: March 01, 2012, 02:43:06 pm »
SFML 2 is complete, but there's still one change to do, and it will possibly impact all the classes and functions. So... yeah, wait a little bit more :D
Laurent Gomila - SFML developer

 

anything