Scaffold the pure game model
- 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).
This commit is contained in:
32
src/logic/Board.h
Normal file
32
src/logic/Board.h
Normal file
@ -0,0 +1,32 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user