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

Author Topic: Weird tilemap issue  (Read 2812 times)

0 Members and 1 Guest are viewing this topic.

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Weird tilemap issue
« on: March 15, 2017, 05:36:10 pm »
This is how it should look normally.


But sometimes when I move around the camera by using view.setCenter()

Weird artifacts appear.

I have tried adding (.5f, .5f) to the center position of view. Then the issue is mostly gone. But rarely, I can still see the artifacts.
I am using a gtx 1070.



Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Weird tilemap issue
« Reply #1 on: March 15, 2017, 09:07:37 pm »
It's not weird; it's very common indeed.

The view's size should be identical to the window's size (or a power of two), the view's center should be rounded to the nearest integer (or pixel if different), view should not be rotated or otherwise zoomed, all tiles vertices should be placed at integer (or pixel if different) positions and not rotated or scaled (maybe a power of two)...

The much simpler solution is to draw everything (or at least the part you want to show) 1:1 on a render texture and then position, scale and rotate the sprite that displays the render texture. This shows no holes - ever.

Another solution is just use a TileMap that already implements this: Selba Ward's Tile Map does so ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Weird tilemap issue
« Reply #2 on: March 15, 2017, 09:58:26 pm »
Thank you.
I researched this issue further and solved it by applying the technique I saw from here:
https://github.com/fallahn/sfml-tmxloader/blob/c7c6f3da0397657409f35f754c84aa5a4785202e/src/MapLoaderPrivate.cpp#L687

 

anything