Skip to content

Commit

Permalink
Fix off-by-one error in map item layer renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed May 8, 2023
1 parent f3e7235 commit 8df81f2
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col,

foreach (var item in items)
{
//note: col is offset by 1. I'm not sure why this is needed. Maybe I did something wrong when translating the packets...
var itemPos = GetDrawCoordinatesFromGridUnits(col + 1, row);
var itemPos = GetDrawCoordinatesFromGridUnits(col, row);
var itemTexture = _mapItemGraphicProvider.GetItemGraphic(item.ItemID, item.Amount);

spriteBatch.Draw(itemTexture,
Expand All @@ -57,10 +56,5 @@ public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col,

bool IsItemAt(MapItem item) => item.X == col && item.Y == row;
}

protected override Vector2 GetDrawCoordinatesFromGridUnits(int gridX, int gridY)
{
return _gridDrawCoordinateCalculator.CalculateBaseLayerDrawCoordinatesFromGridUnits(gridX, gridY);
}
}
}

0 comments on commit 8df81f2

Please sign in to comment.