Skip to content

Commit

Permalink
Add missing getTilesetColumns method
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMnD committed Mar 16, 2020
1 parent 6c261c9 commit d966024
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion export_to_godot_tilemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class GodotTilemapExporter {
/**
* Tileset should expose columns ... but didn't at the moment so we
* calculate them base on the image width and tileWidth
* return {String}
* return {number}
**/
getTilesetColumns(tileset) {
// noinspection JSUnresolvedVariable
Expand Down
19 changes: 16 additions & 3 deletions export_to_godot_tileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class GodotTilesetExporter {

let tile = tiles[index];

const tilesetColumns = this.getTilesetColumns();
if ((autotileCoordinates.x + 1) > tilesetColumns) {
autotileCoordinates.x = 0;
autotileCoordinates.y += 1;
}

// noinspection JSUnresolvedVariable
if (tile.objectGroup !== null) {

Expand All @@ -64,9 +70,6 @@ class GodotTilesetExporter {
}

autotileCoordinates.x += 1;
if ((index) < this.tileset.columns) {
autotileCoordinates.y += 1;
}

}

Expand Down Expand Up @@ -96,6 +99,16 @@ class GodotTilesetExporter {
);
}

/**
* Tileset should expose columns ... but didn't at the moment so we
* calculate them base on the image width and tileWidth
* return {number}
**/
getTilesetColumns() {
// noinspection JSUnresolvedVariable
return Math.floor(this.tileset.imageWidth / this.tileset.tileWidth);
}

getTilesetTemplate() {
// noinspection JSUnresolvedVariable
return `[gd_resource type="TileSet" load_steps=3 format=2]
Expand Down

0 comments on commit d966024

Please sign in to comment.