Skip to content

Commit 91189fd

Browse files
committedOct 2, 2021
fix hardcoded tile texture coordinates (#14)
1 parent 567bffe commit 91189fd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎src/Layer.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,18 @@ void Layer::updateTileVerticesPos(const Tile& tile) const {
176176
}
177177

178178
void Layer::updateTileVerticesTex(const Tile& tile) const {
179+
auto cell_size = getCellSize();
179180
IntPoint modif[4];
180-
auto cell_size_i = static_cast<int>(getCellSize());
181+
IntPoint tex_coo[4] = {{0, 0}, {cell_size, 0}, {cell_size, cell_size}, {0, cell_size}};
182+
181183
if (tile.flipX) {
182-
modif[0].x = cell_size_i; modif[1].x = -cell_size_i;
183-
modif[3].x = cell_size_i; modif[2].x = -cell_size_i;
184+
modif[0].x = cell_size; modif[1].x = -cell_size;
185+
modif[3].x = cell_size; modif[2].x = -cell_size;
184186
}
185187
if (tile.flipY) {
186-
modif[0].y = cell_size_i; modif[1].y = cell_size_i;
187-
modif[3].y = -cell_size_i; modif[2].y = -cell_size_i;
188+
modif[0].y = cell_size; modif[1].y = cell_size;
189+
modif[3].y = -cell_size; modif[2].y = -cell_size;
188190
}
189-
UIntPoint tex_coo[4] = { {0, 0}, {16, 0}, {16, 16}, {0, 16}};
190191
for (int i = 0; i < 4; ++i) {
191192
tile.vertices[i].tex.x = tile.texture_position.x+tex_coo[i].x+modif[i].x;
192193
tile.vertices[i].tex.y = tile.texture_position.y+tex_coo[i].y+modif[i].y;

0 commit comments

Comments
 (0)
Please sign in to comment.