Pan, zoom, and mouse-to-gridsquare translation that I can be proud of. Cleanup required, though

This commit is contained in:
John McCardle 2023-03-04 19:04:05 -05:00
commit a4b6c2c428
3 changed files with 115 additions and 99 deletions

View file

@ -253,16 +253,16 @@ void UITestScene::doAction(std::string name, std::string type)
if (ACTION("sound_test", "start")) { sound.play(); }
if (ACTION("left", "start")) {
grid.center_x -= 0.5;
grid.center_x -= 1;
}
if (ACTION("right", "start")) {
grid.center_x += 0.5;
grid.center_x += 1;
}
if (ACTION("up", "start")) {
grid.center_y -= 0.5;
grid.center_y -= 1;
}
if (ACTION("down", "start")) {
grid.center_y += 0.5;
grid.center_y += 1;
}
if (ACTION("zoom_down", "start")) {
if (grid.zoom > 0.75f) grid.zoom -= 0.25f;
@ -293,7 +293,7 @@ void UITestScene::doAction(std::string name, std::string type)
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;
std::cout << "At (" << tx << ", " << ty << "): " << gridsq.tilesprite << " Center: (" << grid.center_x << ", " << grid.center_y << ")" << std::endl;
}
}