diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:08:36 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:08:36 +0100 |
commit | 20fc8401083e23e414feae2a9a4d217b228b8f15 (patch) | |
tree | 08c9e9c4ddcde5438eb54f6b051895c0896f935b /mwe/resource-manager/map_layer.cpp | |
parent | 60669b60e63532bc264ecd6d106bd15f0688a5b6 (diff) | |
parent | 121b64b1cb6cfead5814070c8b0185d3d7308095 (diff) |
Merge remote-tracking branch 'origin/master' into niels/rendering_color
Diffstat (limited to 'mwe/resource-manager/map_layer.cpp')
-rw-r--r-- | mwe/resource-manager/map_layer.cpp | 41 |
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); } } |