Check in windows

This commit is contained in:
2019-11-06 14:03:47 -07:00
parent b85ed10846
commit 9b0d86a995
14 changed files with 41 additions and 20 deletions

BIN
Hw6/Archive.zip Normal file

Binary file not shown.

View File

@@ -20,7 +20,7 @@ void LifeSimulator::insertPattern(const Pattern& pattern, std::uint8_t startX, s
{
startX += 1;
startY += 1;
std::cout << pattern.getCell(0, 0) << std::endl;
// std::cout << pattern.getCell(0, 0) << std::endl;
if (((currentScreen.size() - 1) >= pattern.getSizeY() + startY) &&
(pattern.getSizeX() + startX) <= (currentScreen[0].size() - 1))
{

View File

@@ -12,7 +12,7 @@ class PatternAcorn : public Pattern
private:
std::uint8_t X;
std::uint8_t Y;
std::array<std::array<bool, 4>, 4> cells{};
std::array<std::array<bool, 9>, 5> cells{};
public:
PatternAcorn();
@@ -26,7 +26,7 @@ class PatternAcorn : public Pattern
};
[[nodiscard]] bool getCell(std::uint8_t x, std::uint8_t y) const override
{
return cells[x][y];
return cells[y][x];
};
};

View File

@@ -26,7 +26,7 @@ class PatternBlinker : public Pattern
};
[[nodiscard]] bool getCell(std::uint8_t x, std::uint8_t y) const override
{
return cells[x][y];
return cells[y][x];
};
};

View File

@@ -25,7 +25,7 @@ class PatternBlock : public Pattern
};
[[nodiscard]] bool getCell(std::uint8_t x, std::uint8_t y) const override
{
return cells[x][y];
return cells[y][x];
};
};

View File

@@ -26,7 +26,7 @@ class PatternGlider : public Pattern
};
[[nodiscard]] bool getCell(std::uint8_t x, std::uint8_t y) const override
{
return cells[x][y];
return cells[y][x];
};
};

View File

@@ -14,7 +14,6 @@ PatternGosperGliderGun::PatternGosperGliderGun() :
cells[i][j] = false;
}
}
//Guns
cells[3][35] = true;
cells[3][36] = true;

View File

@@ -12,7 +12,7 @@ class PatternGosperGliderGun : public Pattern
private:
std::uint8_t X;
std::uint8_t Y;
std::array<std::array<bool, 4>, 4> cells{};
std::array<std::array<bool, 38>, 11> cells{};
public:
PatternGosperGliderGun();
@@ -26,7 +26,7 @@ class PatternGosperGliderGun : public Pattern
};
[[nodiscard]] bool getCell(std::uint8_t x, std::uint8_t y) const override
{
return cells[x][y];
return cells[y][x];
};
};

View File

@@ -22,5 +22,4 @@ void RendererConsole::render(const LifeSimulator& simulation)
}
}
}
//rlutil::showcursor();
}

Binary file not shown.

View File

@@ -14,26 +14,29 @@
int main()
{
RendererConsole rendererConsole = RendererConsole();
LifeSimulator lifeSimulator = LifeSimulator(100, 100);
RendererConsole rendererConsole;
PatternAcorn patternAcorn;
PatternBlock patternBlock;
PatternGosperGliderGun patternGosperGliderGun;
PatternGlider patternGlider;
PatternBlinker patternBlinker;
LifeSimulator lifeSimulator = LifeSimulator(100, 28);
LifeSimulator lifeSimulator1 = LifeSimulator(100, 28);
LifeSimulator lifeSimulator2 = LifeSimulator(100, 28);
PatternBlinker patternBlinker = PatternBlinker();
lifeSimulator.insertPattern(patternBlinker, 50, 10);
PatternGlider patternGlider = PatternGlider();
lifeSimulator.insertPattern(patternGlider, 5, 10);
PatternGosperGliderGun patternGosperGliderGun = PatternGosperGliderGun();
lifeSimulator.insertPattern(patternGosperGliderGun, 20, 20);
lifeSimulator1.insertPattern(patternGosperGliderGun, 0, 0);
PatternBlock patternBlock = PatternBlock();
lifeSimulator.insertPattern(patternBlock, 0, 10);
PatternAcorn patternAcorn = PatternAcorn();
lifeSimulator.insertPattern(patternAcorn, 0, 23);
lifeSimulator2.insertPattern(patternAcorn, 5, 5);
int x = 0;
while (x < 400)
while (x < 200)
{
rendererConsole.render(lifeSimulator);
lifeSimulator.update();
@@ -41,5 +44,25 @@ int main()
std::this_thread::sleep_for(std::chrono::milliseconds(10));
x++;
}
int y = 0;
while (y < 200)
{
rendererConsole.render(lifeSimulator1);
lifeSimulator1.update();
std::cout << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
y++;
}
int z = 0;
while (z < 200)
{
rendererConsole.render(lifeSimulator2);
lifeSimulator2.update();
std::cout << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(25));
z++;
}
return 0;
}