for(itr = m_players.begin(); itr != m_players.end(); itr++)
{
x = itr->GetPlayerX() / 2;
y = itr->GetPlayerZ() / 2;
glPrint(x, y, itr->GetName());
}
Print character names.
Hi there, I just wonder how do they print the names over the characters in
rpg games?
let say I print the text like this.
I dont know exacly how to do this, But I want to print names for
eatch player in the m_players over the character.
How do you guys do this?
hope anyone can point me to a good solution.
thanks.
Its not that, I can print the font I only whant to know how to calc the x,y for the text using player x,z to get the name over the players.
Well you want the y co-ordinate to be that of the player minus their height, & minus again the height of the text, minus some padding as well (that's if -y is up)
You also want some kind of function to tell you the width of the text in advance, then subtract half of that from the x to center it about a point.
If the x marks the center of the player then use that (minus half the text width)
If it marks the x then first add half the player width then subtract half the text width (then minus half the text width)
Try to get some paper to sketch this & see if you can "see" it
You also want some kind of function to tell you the width of the text in advance, then subtract half of that from the x to center it about a point.
If the x marks the center of the player then use that (minus half the text width)
If it marks the x then first add half the player width then subtract half the text width (then minus half the text width)
Try to get some paper to sketch this & see if you can "see" it
I dont understand exacly what you mean, but something like this?
y = ((GetPlayerY() - SCREEN_HEIGHT) - TextHeight);
x = ((SCREEN_WIDTH/2 - TextWidth/2) + (GetPlayerX()/2 / TextWidth/2) - TextWidth/2));
im not that good at english.
correct me.
y = ((GetPlayerY() - SCREEN_HEIGHT) - TextHeight);
x = ((SCREEN_WIDTH/2 - TextWidth/2) + (GetPlayerX()/2 / TextWidth/2) - TextWidth/2));
im not that good at english.
correct me.
Okay well it depends what the position of the player actually means. I shall give 2 examples:
I hope that's easier to understand
padding=LineHeight*0.5 (just to move it away from the head alittle)Position is the bottomleft corner of the player: x =GetPlayerX()+PlayerWidth*0.5-TextWidth*0.5 y =GetPlayerY()-PlayerHeight-TextHeight-paddingPosition is the middle of the player: x =GetPlayerX()-TextWidth*0.5 y =GetPlayerY()-PlayerHeight*0.5-TextHeight-paddingIf up is +y then change the - in the y formula to a +if(up==+1)formula.y.replace('-','+');
I hope that's easier to understand
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement