From f41f49c1f680b5ef81c423f4d66130af16cd89e7 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Fri, 20 Sep 2024 20:00:25 +0300 Subject: [PATCH] corrected pixel positions --- minimapButton.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/minimapButton.cpp b/minimapButton.cpp index 617847e..724a3d6 100644 --- a/minimapButton.cpp +++ b/minimapButton.cpp @@ -40,8 +40,8 @@ namespace battleship{ for(Player *pl : Game::getSingleton()->getPlayers()) for(Unit *un : pl->getUnits()){ Vector2 coords = Vector2( - int(un->getPos().x / mapSize.x * width) - .5 * width, - int(un->getPos().z / mapSize.z * height) - .5 * height + int(un->getPos().x / mapSize.x * width), + int(un->getPos().z / mapSize.z * height) ); unitMinimapPos.push_back(make_pair(un, coords)); @@ -58,7 +58,7 @@ namespace battleship{ for(u8 *p = asset->image; p != asset->image + size; p += numChannels, pxId += numChannels, numIter++){ Vector2 coords = Vector2( - numIter % asset->width - .5 * asset->width, + -(numIter % asset->width - .5 * asset->width), numIter / asset->width - .5 * asset->height ); float losFactor = .6, pxCol[3]{ @@ -115,8 +115,8 @@ namespace battleship{ void MinimapButton::onClick(){ Vector2 clickPos = getCursorPos(); - float posXRatio = (clickPos.x - pos.x) / size.x; - float posYRatio = (clickPos.y - pos.y) / size.y; + float posXRatio = 1. - (clickPos.x - pos.x) / size.x; + float posYRatio = 1. - (clickPos.y - pos.y) / size.y; Camera *cam = Root::getSingleton()->getCamera(); Vector3 mapSize = Map::getSingleton()->getMapSize();