Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add margin spacing support #82

Merged
merged 5 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: go
# https://github.com/golang/go/issues/31293
dist: xenial
sudo: false
# The follow addons are a requirement for the pixel library
addons:
Expand All @@ -12,6 +14,7 @@ addons:
- libxi-dev
- libopenal-dev
- libasound2-dev
- libgl1-mesa-dev
go:
- tip
- 1.12.x
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Ben @bcvery1
- Andrea Manzini @ilmanzo
- Y.Horie @u5surf
- Thomas Lacroix @TooHTooH
- Patrick Erber @perber

5 changes: 2 additions & 3 deletions tile.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ func (t *DecodedTile) setSprite(columns, numRows int, ts *Tileset) {
if t.sprite == nil {
// Calculate the framing for the tile within its tileset's source image
x, y := tileIDToCoord(t.ID, columns, numRows)

iX := float64(x) * float64(ts.TileWidth)
iX := float64(x)*float64(ts.TileWidth) + float64(ts.Margin+ts.Spacing*x-1)
fX := iX + float64(ts.TileWidth)
iY := float64(y) * float64(ts.TileHeight)
iY := float64(y)*float64(ts.TileHeight) + float64(ts.Margin+ts.Spacing*y-1)
fY := iY + float64(ts.TileHeight)

t.sprite = pixel.NewSprite(ts.sprite.Picture(), pixel.R(iX, iY, fX, fY))
Expand Down