mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 14:24:10 +08:00
The calculation process has been modified, and now it is performed directly in the gameapplication class
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user