View Full Version : My score is displaying funny numbers, need help!

01-03-2013, 10:16 AM
Ok so I used one of my old codes which displays the integer 0 next to "score" at the beginning of the program

However in my current program every time I run the program it displays 'score' but instead of displaying 0 next to it, it displays random numbers such as 37363160 and every time i run the program the random numbers change from the previous one.

note: when i click on the window the random numbers blink....

Why isn't it displaying 0? My friend tried the exact same code and it worked for him

Here's my code in order the important parts)

char displayscore [10]; // string
int score = 1;

void renderBitmapString(float x, float y, float z, void *font, char *string)
char *c; glRasterPos3f(x,y,z);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);

and in my void renderscene

//glTranslatef (25.0, -31.0, 20.0);
sprintf(displayscore,"Score %u");
renderBitmapString(-250,180,0.0,GLUT_BITMAP_HELVETICA_12,displayscore) ;

01-03-2013, 02:58 PM

next to %u, I missed the score....

so sprintf(displayscore,"Score %u", score);

little things lol