The calculation process has been modified, and now it is performed directly in the gameapplication class

This commit is contained in:
2025-12-24 14:01:25 +08:00
parent cefe4a37b7
commit e8c6cee046
15 changed files with 54 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
#include "CoordinateConverter.h"
#include "utils/CoordinateTools.h"
CoordinateConverter::CoordinateConverter(SDL_Renderer* renderer) : m_renderer(renderer) {
}
@@ -8,8 +8,8 @@ CoordinateConverter::~CoordinateConverter() {
}
std::optional<std::pair<int, int>> CoordinateConverter::ScreenToBoard(float screenX, float screenY, BoardArea area) {
auto [mouseX, mouseY] = physicalToLogical(screenX, screenY, m_renderer);
std::optional<std::pair<int, int>> CoordinateConverter::ScreenToBoard(int mouseX, int mouseY, BoardArea area) {
// 判断是否点击在棋盘区域内
if (mouseX < area.x || mouseX >= area.x + area.cellSize * area.cols ||
mouseY < area.y || mouseY >= area.y + area.cellSize * area.rows) {

View File

@@ -8,7 +8,7 @@ public:
CoordinateConverter(SDL_Renderer* renderer);
~CoordinateConverter();
// 将物理坐标转化成逻辑坐标
std::optional<std::pair<int, int>> ScreenToBoard(float screenX, float screenY, BoardArea aera);
std::optional<std::pair<int, int>> ScreenToBoard(int mouseX, int mouseY, BoardArea aera);
private:
SDL_Renderer* m_renderer;