#pragma once #include #include #include #include #include using pos = std::pair; enum class DIRECTION { UP, DOWN, RIGHT, LEFT, NONE }; class Board { public: explicit Board(int splitting = 6); ~Board(); void draw(sf::RenderWindow& window); bool moveSelection(const DIRECTION& direction); void onSelectionMode(); bool isWinCondition() const; private: struct Cell { std::vector::size_type inital_index; std::vector::size_type current_index; sf::Sprite *sprite; static float side_length; }; using Cells = std::vector; using RefCells = std::vector; sf::VertexArray rect_selection; Cells::size_type selection_index; Cells::size_type cells_on_width; // amount of cells on horizontal side of board Cells::size_type cells_on_height; // amount of cells on vertical side of board Cells vec_field; RefCells vec_ref; // map to actual index sf::Texture global_texture; bool on_selection; void setSelectionVertex(Cells::size_type index); void swapCells(Cells::size_type curr_cell_ind, Cells::size_type swap_cell_ind); Cells::iterator cellByCurrentIndex(Cells::size_type index); };