Skip to main content
GameDev.net gamedev.net
🔒 Locked

Printing Text Problem

Started by Bezzant Nov 21, 2000 at 3:35 PM 7 replies 400+ views
Original Post
Bezzant
Bezzant
Hi, Im making a game and I want to set up a score thing.... I have the text that says player 1 then I want it to display the score heres what I put in..
  
int score = 0;   

 	glRasterPos2f( 5.5f, 5.5f);   // text position

 	glPrint(score);	   // dispay score

  
When I compile this I get an error saying that It can''t display the int score then something to do with a char... Theres obviously a way around this problem but I can''t figure it out! I know it must have something to do with the glPrint function but what!.... Hope somebody can help Thanks in advance Alan IF YA SMELL... WHAT THE BEZZ IS COOKIN''''
PrinceofZ
PrinceofZ
you can make it like this:
glPrint("%7.0f", score);

%means that there is something not to print behind it, 7 means 7 digits before the dot and 0 nothing behind the dot, and f that it is a float...
u wouldnt understand a german quote :)
Bezzant
Bezzant

I put in
  
int score = 0;

glPrint("Player 1: %7.0f", score);



Put It does not work..... It just displays "Player 1:" but no score

Does anybody have an other idea

Alan

IF YA SMELL... WHAT THE BEZZ IS COOKIN''''

DemOSh
DemOSh
use sprintf. something like this

{
char scorestr[32];
int score = 0;

sprintf(scorestr, "Player 1: %i", score);
glPrint(scorestr);
}

Im assuming you know how the printf functions work as far as formatting goes. If you dont, check msdn or ask...
Dunge
Dunge
GLFloat score = 0.0f;
glPrint("Player 1: %7.0f", score);
Nyko
Nyko
This works for me:
  
int score = 0;
glPrint("Player 1: %d",num);


CyberBotX
CyberBotX
Wouldn''t glPrint("Player 1: %i", score) work out?
Nyko
Nyko
Yea, both %d and %i will give you the same value.
I just use %d, ''cause it make me think more of a decimal value.
Bezzant
Bezzant
Thanks all, you have helped me a great deal It''s great to see that you are all willing to help out other people

Thanks
Alan

IF YA SMELL... WHAT THE BEZZ IS COOKIN''''

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.