From eecf4b1e666211a13afa56f93477c55e8fd01621 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 19:51:54 +0200 Subject: feat: implement game of life --- src/game/cell_helper.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/game/cell_helper.hpp (limited to 'src/game/cell_helper.hpp') diff --git a/src/game/cell_helper.hpp b/src/game/cell_helper.hpp new file mode 100644 index 0000000..cf41c6f --- /dev/null +++ b/src/game/cell_helper.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "interfaces/cell_helper.hpp" +#include "interfaces/matrix.hpp" + +#include "engine/data/vector2.hpp" + +#include +#include + +template +class CellHelper : public ICellHelper +{ +public: + explicit CellHelper(const IMatrix &matrix) noexcept; + + [[nodiscard]] auto is_cell_dying(const Vector2 &cell_pos) const noexcept + -> bool override; + + [[nodiscard]] auto + get_birth_cell_positions(const std::list &cell_positions) const noexcept + -> std::list override; + + [[nodiscard]] auto find_neighbours(const Vector2 &cell_pos) const noexcept + -> std::list override; + +private: + const IMatrix &_matrix; + + static auto _get_position_neighbours(const Vector2 &position) noexcept + -> std::list; +}; + +#include "cell_helper.tpp" -- cgit v1.2.3-18-g5258