In my code below, I want to display the text contained in the variable finalscore. I know how simple it sounds, but I can't figure it out. Thanks!

#include <glut.h>
#include <cmath>
#include <cstdlib>
#include <time.h>
#include <string>
using namespace std;

GLfloat tplayer;
GLfloat tobject;

time_t Start_t, End_t;
double angle = 0;
double angleadd = 0.2;
int c = 0;
int d = 0;
int e = 10;
int f = 10;
int random, timeelapsed, finalscore;
int score = 0;
int eplus = e + 6;
int eminus = e - 6;
int fplus = f + 6;
int fminus = f - 6;
int mint = 2;

void movecube(){
	e = rand() % 190 - 95;
	f = rand() % 190 - 95;
	End_t = time(NULL);
	timeelapsed = difftime(End_t, Start_t);
	finalscore = score / timeelapsed;
	
}

void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glClear(GL_DEPTH_BUFFER_BIT);
    glPushMatrix(); 
	glTranslatef(c, d, 0);
    glRotatef(angle, 0, 0.5, 1);
	glColor3f (0, 0, 1);
    glutWireSphere(5, 10, 10);
    glPopMatrix();
	glPushMatrix();
	glTranslatef(e, f, 0);
    glRotatef(angle, 0, 0.5, 1);
	glColor3f (1, 0, 0);
    glutWireCube(3);
    glPopMatrix();
    glutSwapBuffers();
}

void KeySet() { DWORD old = 0;
SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &old, 0);
SystemParametersInfo(SPI_SETKEYBOARDDELAY,0, &old, 0);
}

void keyboard(unsigned char key, int x, int y)
{
	KeySet();
    if(key == 27) exit (0);
	else if( (key == 119) && (95 > d) ){
	d = d + mint;
	eplus = e + 6;
	eminus = e - 6;
	fplus = f + 6;
	fminus = f - 6;
	if( (c < eplus) && (c > eminus) ){
		if( (d < fplus) && (d > fminus) ){
			score = score + 1;
			movecube();
		}
	}
	}
	else if( (key == 115) && (d > -95) ){
	d = d - mint;
	eplus = e + 6;
	eminus = e - 6;
	fplus = f + 6;
	fminus = f - 6;
	if( (c < eplus) && (c > eminus) ){
		if( (d < fplus) && (d > fminus) ){
			score = score + 1;
			movecube();
		}
	}
	}
	else if( (key == 97) && (c > -95) ){
	c = c - mint;
	eplus = e + 6;
	eminus = e - 6;
	fplus = f + 6;
	fminus = f - 6;
	if( (c < eplus) && (c > eminus) ){
		if( (d < fplus) && (d > fminus) ){
			score = score + 1;
			movecube();
		}
	}
	}
	else if( (key == 100) && (95 > c) ){
	c = c + mint;
	eplus = e + 6;
	eminus = e - 6;
	fplus = f + 6;
	fminus = f - 6;
	if( (c < eplus) && (c > eminus) ){
		if( (d < fplus) && (d > fminus) ){
			score = score + 1;
			movecube();
		}
	}
	}
}

void idle()
{
    angle += angleadd;
    glutPostRedisplay();
}
 
int main (int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize (800, 800);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("Space Journey");
    glClearColor (0, 0, 0, 0);
    glColor3f (1, 1, 1);
    glEnable (GL_DEPTH_TEST);
    glMatrixMode (GL_MODELVIEW);
    glOrtho(-100, 100, -100, 100, -100, 100);
    glutDisplayFunc (display);
	glutKeyboardFunc (keyboard);
	glutIdleFunc (idle);
	glutFullScreen ();
	movecube();
	Start_t = time(NULL);
    glutMainLoop ();
    return 0;
}

Additionally, how would I eliminate the delay that occurs when I press a key? SPI_SETKEYBOARDDELAY just isn't cutting it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.