I have made a small game engine in OpenGL/C++.
It simply draws a grid where the user can move, the user simply presses up/down/right/left to move 1 place in the respected direction. How could I capture a click from a user, and then convert the position of the click to a 'cell' of my grid. My Grid is :
void drawWorld(void)
{
glColor3f(1.0f,0.0f,0.0f);
DrawBox(-0.5f,-0.5f,0.0f,24.0f,24.0f); //24x24 grid
}
void DrawBox(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
{
glBegin(GL_QUADS);
glVertex3f(x,y,z);
glVertex3f(x+width,y,z);
glVertex3f(x+width,y+height,z);
glVertex3f(x,y+height,z);
glEnd();
}
Is just a 24.0f by 24.0f sqare. We are using a camera, using gluLookAt to view this square so that it looks like a floor.
So how would be be able to change the click of the user on the grid, to actual grid positions.
(ie. 3.4f,5.5f) ,so that we could the user to that place. (btw, we have already made code for the movements)