blob: 59b19a9ae04dcfe0f0270d3ed9625ac876051a90 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "LifeSimulator.hpp"
#include "Pattern.hpp"
#include "PatternAcorn.hpp"
#include "PatternGosperGliderGun.hpp"
#include "PatternRandom.hpp"
#include "RendererConsole.hpp"
#include "rlutil.h"
#include <cstdint>
#include <thread>
const uint32_t STEPS = 1000000;
const uint32_t SLEEP_MS = 50;
const bool POPULATE_RAND = false;
int main()
{
std::uint8_t rows = static_cast<std::uint8_t>(rlutil::trows());
std::uint8_t cols = static_cast<std::uint8_t>(rlutil::tcols());
LifeSimulator simulation(cols, rows);
if (!POPULATE_RAND)
{
std::uint8_t acornOffsetX = 40;
std::uint8_t acornOffsetY = 20;
PatternGosperGliderGun patternGun;
// PatternAcorn patternAcorn;
if (cols > patternGun.getSizeX() && rows > patternGun.getSizeY())
simulation.insertPattern(patternGun, 0, 0);
// if (cols > patternAcorn.getSizeX() + acornOffsetX && rows > patternAcorn.getSizeY() + acornOffsetY)
// simulation.insertPattern(patternAcorn, acornOffsetX, acornOffsetY);
}
else
{
PatternRandom patternRandom(cols, rows, 1);
simulation.insertPattern(patternRandom, 0, 0);
}
RendererConsole renderer;
rlutil::cls();
rlutil::saveDefaultColor();
for (std::uint32_t i = 0; i < STEPS; i++)
{
rlutil::hidecursor();
renderer.render(simulation);
simulation.update();
if (SLEEP_MS > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
rlutil::showcursor();
}
return 0;
}
|