Screen to Grid is working pretty reliably, even if switching to float coordinates did make zoom at high values a bit wobbly.

This commit is contained in:
John McCardle 2023-03-03 22:26:38 -05:00
commit 6a4150ec05
3 changed files with 19 additions and 4 deletions

View file

@ -283,10 +283,19 @@ void UITestScene::doAction(std::string name, std::string type)
}
if (ACTION("gridtests", "start")) {
int tx, ty;
auto mousepos = sf::Mouse::getPosition(game->getWindow());
/*
GridPoint* pgrid = grid.atScreenPixel(mousepos.x, mousepos.y, &tx, &ty);
std::cout << "\ntx: " << tx << " ty: " << ty << std::endl;
*/
grid.screenToGrid(mousepos.x, mousepos.y, tx, ty);
if (grid.inBounds(tx, ty)) {
auto gridsq = grid.at(tx, ty);
std::cout << "At (" << tx << ", " << ty << "): " << gridsq.tilesprite << std::endl;
}
}
// after processing: set actionState