Rename GameRenderer to BoardRenderer

This commit is contained in:
2025-12-13 18:56:50 +08:00
parent fccff79a6a
commit 98a7b34bfa
7 changed files with 23 additions and 23 deletions

View File

@@ -0,0 +1,57 @@
#pragma once
#include "utils/Config.h"
#include <SDL3/SDL.h>
#include <optional>
#include <utility>
struct PlayerColors {
SDL_Color P1 = {255, 0, 0, 255}; // 红色
SDL_Color P2 = {0, 0, 255, 255}; // 蓝色
SDL_Color selected = {255, 255, 0, 255}; // 黄色(选中状态)
};
class Board;
class BoardRenderer
{
private:
SDL_Renderer* m_renderer = nullptr;
int m_Width;
int m_Height;
int m_cellSize;
int m_boardRow = 7;
int m_boardCOL = 7;
const Board* m_board = nullptr;
// 棋子绘制相关
float m_pieceRadiusRatio = 0.8f; // 棋子半径相对于格子大小的比例
PlayerColors m_colors;
public:
BoardRenderer(int WIDTH, int HEIGHT, SDL_Renderer* renderer);
~BoardRenderer();
// 渲染画面
// 初始化加载纹理
bool initialize();
// 设置棋盘
void setBoard(const Board* board);
// 渲染函数
// 绘制背景
void drawBackground();
//绘制棋盘
void drawBoard();
// 绘制棋子
void drawPiece(std::optional<std::pair<int, int>> selectedPiece = std::nullopt);
BoardArea getBoardArea() const;
};