aboutsummaryrefslogtreecommitdiff
path: root/mwe/resource-manager/map_layer.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:27:58 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:27:58 +0100
commit03e493012edc106b00bc5676c1830ce2085a7ff9 (patch)
treeff06d4314552e82f98d08c52d7a15edb3a74436e /mwe/resource-manager/map_layer.cpp
parent21f5b66d0bcc13d903800adf3bb614e380ff8591 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/sorting_rendering
Diffstat (limited to 'mwe/resource-manager/map_layer.cpp')
-rw-r--r--mwe/resource-manager/map_layer.cpp41
1 files changed, 13 insertions, 28 deletions
diff --git a/mwe/resource-manager/map_layer.cpp b/mwe/resource-manager/map_layer.cpp
index 6339707..17792a6 100644
--- a/mwe/resource-manager/map_layer.cpp
+++ b/mwe/resource-manager/map_layer.cpp
@@ -20,8 +20,7 @@ bool MapLayer::create(const tmx::Map & map, std::uint32_t layerIndex,
const auto & tileSets = map.getTilesets();
const auto tintColour = layer.getTintColour();
- const SDL_Colour vertColour
- = {tintColour.r, tintColour.g, tintColour.b, tintColour.a};
+ const SDL_Colour vertColour = {tintColour.r, tintColour.g, tintColour.b, tintColour.a};
for (auto i = 0u; i < tileSets.size(); ++i) {
//check tile ID to see if it falls within the current tile set
@@ -40,8 +39,7 @@ bool MapLayer::create(const tmx::Map & map, std::uint32_t layerIndex,
for (auto x = 0u; x < mapSize.x; ++x) {
const auto idx = y * mapSize.x + x;
if (idx < tileIDs.size() && tileIDs[idx].ID >= ts.getFirstGID()
- && tileIDs[idx].ID
- < (ts.getFirstGID() + ts.getTileCount())) {
+ && tileIDs[idx].ID < (ts.getFirstGID() + ts.getTileCount())) {
//tex coords
auto idIndex = (tileIDs[idx].ID - ts.getFirstGID());
float u = static_cast<float>(idIndex % tileCountX);
@@ -55,36 +53,24 @@ bool MapLayer::create(const tmx::Map & map, std::uint32_t layerIndex,
v /= textures[i]->getSize().y;
//vert pos
- const float tilePosX
- = static_cast<float>(x) * mapTileSize.x;
- const float tilePosY
- = (static_cast<float>(y) * mapTileSize.y);
+ const float tilePosX = static_cast<float>(x) * mapTileSize.x;
+ const float tilePosY = (static_cast<float>(y) * mapTileSize.y);
//push back to vert array
- SDL_Vertex vert
- = {{tilePosX, tilePosY}, vertColour, {u, v}};
+ SDL_Vertex vert = {{tilePosX, tilePosY}, vertColour, {u, v}};
verts.emplace_back(vert);
- vert = {{tilePosX + mapTileSize.x, tilePosY},
- vertColour,
- {u + uNorm, v}};
+ vert = {{tilePosX + mapTileSize.x, tilePosY}, vertColour, {u + uNorm, v}};
verts.emplace_back(vert);
- vert = {{tilePosX, tilePosY + mapTileSize.y},
- vertColour,
- {u, v + vNorm}};
+ vert = {{tilePosX, tilePosY + mapTileSize.y}, vertColour, {u, v + vNorm}};
verts.emplace_back(vert);
- vert = {{tilePosX, tilePosY + mapTileSize.y},
- vertColour,
- {u, v + vNorm}};
+ vert = {{tilePosX, tilePosY + mapTileSize.y}, vertColour, {u, v + vNorm}};
verts.emplace_back(vert);
- vert = {{tilePosX + mapTileSize.x, tilePosY},
- vertColour,
- {u + uNorm, v}};
+ vert = {{tilePosX + mapTileSize.x, tilePosY}, vertColour, {u + uNorm, v}};
verts.emplace_back(vert);
- vert
- = {{tilePosX + mapTileSize.x, tilePosY + mapTileSize.y},
- vertColour,
- {u + uNorm, v + vNorm}};
+ vert = {{tilePosX + mapTileSize.x, tilePosY + mapTileSize.y},
+ vertColour,
+ {u + uNorm, v + vNorm}};
verts.emplace_back(vert);
}
}
@@ -104,7 +90,6 @@ void MapLayer::draw(SDL_Renderer * renderer) const {
assert(renderer);
for (const auto & s : m_subsets) {
SDL_RenderGeometry(renderer, s.texture, s.vertexData.data(),
- static_cast<std::int32_t>(s.vertexData.size()),
- nullptr, 0);
+ static_cast<std::int32_t>(s.vertexData.size()), nullptr, 0);
}
}