From 1e84e2d6ef9370a3443fcd8472779184f6319594 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 15 Mar 2022 11:32:14 -0400 Subject: maybe made the slowdown when zoomed out much better --- src/game.cpp | 12 ++++++------ src/game.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index fc57acc..e9a9fbe 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -55,7 +55,7 @@ void Game::tick( bool invert, bool onlyDark) { - std::vector temp(map.data()); + mapDoubleBuffer = map.data(); for (int y = map.getTop(); y < map.getBottom(); y++) { @@ -91,19 +91,19 @@ void Game::tick( int tempIndex = map.getTrueX(x) + map.getTrueY(y) * map.getWidth(); if (count >= 5) { - temp[tempIndex].tile = Tile::Wall; + mapDoubleBuffer[tempIndex].tile = Tile::Wall; } else { - temp[tempIndex].tile = Tile::Floor; + mapDoubleBuffer[tempIndex].tile = Tile::Floor; } - if (temp[tempIndex].tile != map.at(x,y).tile) { - temp[tempIndex].dirtyRender = true; + if (mapDoubleBuffer[tempIndex].tile != map.at(x,y).tile) { + mapDoubleBuffer[tempIndex].dirtyRender = true; dirtyRender = true; } } } - map.data() = std::move(temp); + std::swap(map.data(), mapDoubleBuffer); } void Game::tick(bool onlyDark) diff --git a/src/game.h b/src/game.h index 93ca81a..f307156 100644 --- a/src/game.h +++ b/src/game.h @@ -68,6 +68,7 @@ public: bool dirtyRender = true; size_t numLamps = 0; size_t numDust = 0; + std::vector mapDoubleBuffer; int player_x = 0; int player_y = 0; -- cgit 1.4.1