From 5324adfe51f1348fc97fe2ee0ca4e4bbd2a6ad64 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 17 Mar 2022 15:28:22 -0400 Subject: 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. --- src/renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/renderer.cpp') 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( if (draw) { - if (game.map.at(x,y).tile != Tile::Wall) { + if (game.map.tile(x,y) != Tile::Wall) { SDL_Rect tileRect {17 * 16, 15 * 16, 16, 16}; SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); @@ -192,7 +192,7 @@ void Renderer::renderGame( SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); } - if (game.map.at(x,y).tile == Tile::Lamp) { + if (game.map.tile(x,y) == Tile::Lamp) { SDL_RenderCopy(ren_.get(), lamp_.get(), nullptr, &rect); } -- cgit 1.4.1