daithyy / Games-Fleadh

'STEEL WRATH' Games Fleadh 2018 - Shoot 'Em Up Game
0 stars 1 forks source link

Tile Tearing #3

Open daithyy opened 6 years ago

daithyy commented 6 years ago

tearing

Description: This appears in-game. When the camera moves along the map, the spaces in between the tiles show their gaps. It is apparent that there is a 1 pixel difference in between each tile. Note that the camera moves in floats, with the tiles set in fixed integer positions.

Cause: The cause of the bug is narrowed down to either the Camera, SimpleTileLayer or Tile classes.

Solution: To temporarily reduce the noticeable lines, the Sampler State of the draw in the tile maps was set to SamplerState.PointClamp

daithyy commented 6 years ago

With the help of a lecturer, we targeted the SimpleTileLayer draw event. He found a temporary solution which adds a 1 pixel offset to the left and right sides to the source rectangle. sp.Draw(_tileSheet, new Rectangle(position.ToPoint(), new Point(t.TileWidth, t.TileHeight)), new Rectangle(t.TileRef._sheetPosX * t.TileWidth+1, t.TileRef._sheetPosY * t.TileHeight, t.TileWidth -1, t.TileHeight), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);