diff options
Diffstat (limited to 'src/simulation.cpp')
| -rw-r--r-- | src/simulation.cpp | 20 | 
1 files changed, 4 insertions, 16 deletions
| 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( | |||
| 235 | 235 | ||
| 236 | void Simulation::render(SDL_Renderer* ren) | 236 | void Simulation::render(SDL_Renderer* ren) | 
| 237 | { | 237 | { | 
| 238 | for (size_t y = 0; y < level_.getSize().h(); y++) | 238 | if (!renderedMap_) | 
| 239 | { | 239 | { | 
| 240 | for (size_t x = 0; x < level_.getSize().w(); x++) | 240 | renderedMap_ = level_.render(ren, Layer::map); | 
| 241 | { | ||
| 242 | int val = 255 - level_.at(x, y) * 10; | ||
| 243 | |||
| 244 | SDL_SetRenderDrawColor(ren, val, val, val, 255); | ||
| 245 | |||
| 246 | SDL_Rect rect { | ||
| 247 | static_cast<int>(x * TILE_SIZE.w()), | ||
| 248 | static_cast<int>(y * TILE_SIZE.h()), | ||
| 249 | TILE_SIZE.w(), | ||
| 250 | TILE_SIZE.h() | ||
| 251 | }; | ||
| 252 | |||
| 253 | SDL_RenderFillRect(ren, &rect); | ||
| 254 | } | ||
| 255 | } | 241 | } | 
| 256 | 242 | ||
| 243 | SDL_RenderCopy(ren, renderedMap_.get(), nullptr, nullptr); | ||
| 244 | |||
| 257 | constexpr Layer renderOrder[] = { Layer::track, Layer::object }; | 245 | constexpr Layer renderOrder[] = { Layer::track, Layer::object }; | 
| 258 | 246 | ||
| 259 | ranges::for_each( | 247 | ranges::for_each( | 
