- Added a pure, SDL-free Board model implementing grid access and clearFullLines(). - Added a small standalone test at test_board.cpp (simple assert-based; not yet wired into CMake).
33 lines
623 B
C++
33 lines
623 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
namespace logic {
|
|
|
|
class Board {
|
|
public:
|
|
static constexpr int Width = 10;
|
|
static constexpr int Height = 20;
|
|
|
|
enum class Cell : uint8_t { Empty = 0, Filled = 1 };
|
|
|
|
Board();
|
|
|
|
void clear();
|
|
|
|
Cell at(int x, int y) const;
|
|
void set(int x, int y, Cell c);
|
|
bool inBounds(int x, int y) const;
|
|
|
|
// Remove and return number of full lines cleared. Rows above fall down.
|
|
int clearFullLines();
|
|
|
|
const std::vector<Cell>& data() const { return grid_; }
|
|
|
|
private:
|
|
std::vector<Cell> grid_; // row-major: y*Width + x
|
|
};
|
|
|
|
} // namespace logic
|