From 41593f09b47537ccae1b19dc390f7d7dbb532937 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 24 Feb 2019 12:50:55 -0500 Subject: Rendering of level map moved to Level class --- src/simulation.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/simulation.cpp') diff --git a/src/simulation.cpp b/src/simulation.cpp index 317e010..4d8ec02 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -235,25 +235,13 @@ void Simulation::tick( void Simulation::render(SDL_Renderer* ren) { - for (size_t y = 0; y < level_.getSize().h(); y++) + if (!renderedMap_) { - for (size_t x = 0; x < level_.getSize().w(); x++) - { - int val = 255 - level_.at(x, y) * 10; - - SDL_SetRenderDrawColor(ren, val, val, val, 255); - - SDL_Rect rect { - static_cast(x * TILE_SIZE.w()), - static_cast(y * TILE_SIZE.h()), - TILE_SIZE.w(), - TILE_SIZE.h() - }; - - SDL_RenderFillRect(ren, &rect); - } + renderedMap_ = level_.render(ren, Layer::map); } + SDL_RenderCopy(ren, renderedMap_.get(), nullptr, nullptr); + constexpr Layer renderOrder[] = { Layer::track, Layer::object }; ranges::for_each( -- cgit 1.4.1