Tweak point conversion to prevent off-grid (negative) points from registering as on the grid

This commit is contained in:
John McCardle 2023-03-04 00:18:19 -05:00
parent b3f946ecb2
commit b0ef1d2303
1 changed files with 4 additions and 0 deletions

View File

@ -70,6 +70,10 @@ void Grid::screenToGrid(int sx, int sy, int& gx, int& gy) {
float ans_x = mouse_x_sq + left_edge; float ans_x = mouse_x_sq + left_edge;
float ans_y = mouse_y_sq + top_edge; float ans_y = mouse_y_sq + top_edge;
// casting float turns -0.5 to 0; I want any negative coord to be OOB
if (ans_x < 0) ans_x = -1;
if (ans_y < 0) ans_y = -1;
gx = ans_x; gx = ans_x;
gy = ans_y; gy = ans_y;
/* /*