diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-17 15:28:22 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-17 15:28:22 -0400 |
commit | 5324adfe51f1348fc97fe2ee0ca4e4bbd2a6ad64 (patch) | |
tree | 6b3ff32f9ad2764405fd73a70e15c960a076ed00 /src/renderer.cpp | |
parent | e0fd87411eb5368fee47e268ae03d073293e58c3 (diff) | |
download | ether-5324adfe51f1348fc97fe2ee0ca4e4bbd2a6ad64.tar.gz ether-5324adfe51f1348fc97fe2ee0ca4e4bbd2a6ad64.tar.bz2 ether-5324adfe51f1348fc97fe2ee0ca4e4bbd2a6ad64.zip |
lotta performance improvements
the two main things: 1) When ticking three times after a lighting change, we no longer iterate over the entire map. Instead, we keep a list of the tiles that have changed and the ones adjacent to them, and we iterate over that list. 2) The map tile type is now stored in a separate array from the rest of the tile data. This is because the tile type is the only thing needed for the cellular automata tick, and thus the only thing that we need to actually copy.
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r-- | src/renderer.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index c8c1746..9744e70 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
@@ -173,7 +173,7 @@ void Renderer::renderGame( | |||
173 | 173 | ||
174 | if (draw) | 174 | if (draw) |
175 | { | 175 | { |
176 | if (game.map.at(x,y).tile != Tile::Wall) { | 176 | if (game.map.tile(x,y) != Tile::Wall) { |
177 | SDL_Rect tileRect {17 * 16, 15 * 16, 16, 16}; | 177 | SDL_Rect tileRect {17 * 16, 15 * 16, 16, 16}; |
178 | SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); | 178 | SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); |
179 | 179 | ||
@@ -192,7 +192,7 @@ void Renderer::renderGame( | |||
192 | SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); | 192 | SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); |
193 | } | 193 | } |
194 | 194 | ||
195 | if (game.map.at(x,y).tile == Tile::Lamp) { | 195 | if (game.map.tile(x,y) == Tile::Lamp) { |
196 | SDL_RenderCopy(ren_.get(), lamp_.get(), nullptr, &rect); | 196 | SDL_RenderCopy(ren_.get(), lamp_.get(), nullptr, &rect); |
197 | } | 197 | } |
198 | 198 | ||