diff --git a/src/application.cpp b/src/application.cpp index 9868249..b6b2559 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -69,6 +69,7 @@ static void PrimaryControls() { if (!isSimulating) { elements::TextButton(CLAY_STRING("Randomize"), style::actionButton, &RandomizeFieldButton); } + elements::Toggle(CLAY_STRING("Debug Info"), style::actionButton, simulation::drawDebugInfo); } } } diff --git a/src/simulation.cpp b/src/simulation.cpp index 54e769b..7da8567 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -9,6 +9,8 @@ #include namespace simulation { +bool drawDebugInfo{ true }; + static std::set living{}; static std::vector overpopulated{}; static std::vector underpopulated{}; @@ -145,6 +147,9 @@ void Draw(SDL_Renderer *renderer, double cellSizePercent) { cellRect.y = (viewOffset.y + cell.y) * cellRect.h; SDL_RenderFillRect(renderer, &cellRect); } + if (!drawDebugInfo) { + return; + } SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); for (Cell const &cell : overpopulated) { cellRect.x = (viewOffset.x + cell.x) * cellRect.w; diff --git a/src/simulation.h b/src/simulation.h index f6d55ab..df68d78 100644 --- a/src/simulation.h +++ b/src/simulation.h @@ -33,6 +33,8 @@ public: CellRange(Cell begin, Cell end) : beginCell{ begin }, endCell{ end } {} CellIterator end() { return CellIterator{ beginCell, endCell, endCell }; } }; +extern bool drawDebugInfo; + void InitializeRandom(size_t livingChance, int64_t fillArea); void Step(); void Draw(SDL_Renderer *renderer, double cellSizePercent);