I think you have a typo in these lines (BAIT and TAILS), it should be divided by 20 instead of 40 (HEAD divides y by 20). That explains why they are showed only on the bottom half of the screen.
byy = by * 16.25 / 40; // should be 20.0 instead of 40
tyy = i * 16.25 / 40; // should be 20.0 instead of 40
Also you are doing integer divisions in the same lines. Use 40.0 instead of 40 to force a float division
/* BAIT */
bxx = bx * 23 / 40.0;
byy = by * 16.25 / 20.0;
/* HEAD */
hxx = hx * 23 / 40.0;
hyy = hy * 16.25 / 20.0;
/* TAIL */
txx = j * 23 / 40.0;
tyy = i * 16.25 / 20.0;
Also you can extract the drawing of the quad to another function, because it is the same code.
void SetLocationE()
{
glLoadIdentity();
glTranslatef(-11.5f, -8.125f, .0f);
}
void drawQuad(float r, float g, float b)
{
// Draw quad
SetLocationE();
float x = j * 23.0 / 40.0;
float y = i * 16.25 / 20.0;
glTranslatef(x, y, zet);
glBegin(GL_QUADS);
//painting
glColor3f(r, g, b);
//drawing TOP RIGHT -> TOP LEFT
// -> BOTTOM LEFT -> BOTTOM RIGHT
glVertex3f(0.15f, 0.15f, .0f); //tr
glVertex3f(-0.15f, 0.15f, .0f); //tl
glVertex3f(-0.15f, -0.15f, .0f); //bl
glVertex3f(0.15f, -0.15f, .0f); //br
glEnd();
}
void ScreenBuffer::RenderToScreen(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* DRAW */
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 40; j++)
{
// select color
if (MAP[i][j] == 'x') {
drawQuad(0.0f, 0.0f, 0.0f);
}
else if (MAP[i][j] == '0')
{
drawQuad(0.0f, 0.3f, 0.1f);
}
else if (MAP[i][j] == 'o')
{
drawQuad(0.0f, 0.7f, 0.2f);
}
}
}
}