Presumably you were given the code as an assignment for a lab or you are using source code. Can you post the code instead of attaching it? It would make it much easier to see what is happening.
I’m assuming your 2nd line number is actually 116, not 98.
116: glTranslatef((gamewidth*i)/2,0,0);
Since your ‘reshape’ function sets the glMatrixMode to GL_MODELVIEW, all your calls to glTranslate are in fact telling the display where to draw.
I’d take another look at your screen size constant definitions:
#define gamewidth 0.7
#define linehigh 4
#define linewidth 0.05
Assuming your game is in landscape mode, it may be better to redefine your constants similar to this:
#define gamewidth 1.3
#define gameheight 1
#define linehigh 4
#define linewidth 0.05
For some reason you are scaling a cube into a line and using that to draw the grid. It would be much easier to use GL_LINES.
Draw horizontal:
glBegin(GL_LINES);
glVertex3f(0.0f, i*16, 0.0f); // origin of the line
glVertex3f(640.0f, i*16, 0.0f); // ending point of the line
glEnd( );
Draw vertical:
glBegin(GL_LINES);
glVertex3f(i*16, 0.0f, 0.0f); // origin of the line
glVertex3f(i*16, 480.0f, 0.0f); // ending point of the line
glEnd( );
Assuming your screen is 640x480.
Who gave you the misleading idea to draw lines with an elongated cube? Very very bad practise If in doubt, search online for ‘drawing line primitives in openGL’. Once you have got the grid drawn then worry about moving objects etc.