#include "RendererConsole.hpp" void RendererConsole::render(const LifeSimulator& simulation) { for (uint8_t y = 0; y < simulation.getSizeY(); ++y) for (uint8_t x = 0; x < simulation.getSizeX(); ++x) { bool alive = simulation.getCell(x, y); auto coord = std::pair(x, y); rlutil::resetColor(); rlutil::locate(x + 1, y + 1); if (!alive && m_previouslyAliveLength.contains(coord) && m_previouslyAliveLength[coord] >= RendererConsole::MAX_ALIVE) { rlutil::setChar(' '); m_previouslyAliveLength.erase(coord); continue; } else if (alive) m_previouslyAliveLength[coord] = 0; if (m_previouslyAliveLength.contains(coord)) { auto colorChar = RendererConsole::PRINT_PER_LIFESPAN[m_previouslyAliveLength[coord]]; rlutil::setColor(colorChar.second); rlutil::setChar(colorChar.first); m_previouslyAliveLength[coord]++; } } }