blob: 76e3d49616cd211ed0d5d553a2c1e2936b27efa8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#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<std::uint8_t, std::uint8_t>(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]++;
}
}
}
|