How do I convert screen coordinates to between -1 and 1?
- by bbdude95
I'm writing a function that allows me to click on my tiles. The origin for my tiles is the center, however, the mouse's origin is the top left. I need a way to transform my mouse coordinates into my tile coordinates.
Here is what I already have (but is not working):
void mouseClick(int button, int state, int x, int y)
{
x -= 400;
y -= 300;
float xx = x / 100; // This gets me close but the number is still high.
float yy = y / 100; // It needs to be between -1 and 1
}