1
Graphics / Check string width in pixels
« on: November 29, 2009, 09:49:20 pm »
How do I know the string width in pixels?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
BTW - Great little game. You just need to have a display of how many lives you have left, unless I didn't understand how it works. Maybe it's all based on how many points you have?
for(int i = 0; i < (int)cg->stars.size(); i++)
{
switch(cg->stars[i].kind)
{
case 0:
{
cg->sprites[sid_star0].SetPosition(cg->stars[i].x, cg->stars[i].y);
cg->sprites[sid_star0].SetRotation(cg->stars[i].rot);
wnd.Draw(cg->sprites[sid_star0]);
}
case 1:
{
cg->sprites[sid_star1].SetPosition(cg->stars[i].x, cg->stars[i].y);
cg->sprites[sid_star1].SetRotation(cg->stars[i].rot);
wnd.Draw(cg->sprites[sid_star1]);
}
}
}
void draw_hud(){
sf::String score, hp;
std::stringstream ss;
score.SetFont(cg->hud_font);
hp.SetFont(cg->hud_font);
ss << (int)cg->player.score;
score.SetText(ss.str().c_str());
ss.str("");
ss << "%" << cg->player.hp;
hp.SetText(ss.str().c_str());
score.SetPosition(24,480-48);
wnd.Draw(score);
hp.SetPosition(400, 480-48);
wnd.Draw(hp);
}