aboutsummaryrefslogtreecommitdiff
path: root/mwe/resource-manager/map_layer.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
commitfee42c67918a9370f7f4e074dba9a677afccf90b (patch)
treec5ed200e3c584fafc4c6bd3df48adeed3cfbd31d /mwe/resource-manager/map_layer.cpp
parented1403aea4412bd479244eae8e2940190e71cd28 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/RenderingParticle
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);
}
}