Jump to content
  • Advertisement
Sign in to follow this  
iGunSlingeRv2

Display Score in DirectX

This topic is 2753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to display a scoring system but Im having difficulty making it add the score into string. Im barely starting in DirectX so I dont know how. Im using DXUT if that helps and in C++. So far this is what I used to display it:

CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );
txtHelper..DrawTextLine(L"Score: ");

I just dont know how to add score.

Share this post


Link to post
Share on other sites
Advertisement
Hi iGunSlingeRv2, i am beginner too so this might not be "proper" way of doing it, but you can try this:

const std::wstring scoreText = L"Score: ";
UINT score = 0;
...
someFunction()
{
...
//update score
score += 50;
}

drawText()
{
...
const UINT maxBufferSize = 20;
wchar_t buffer[maxBufferSize];
_itow_s(score, buffer, maxBufferSize, 10);
std::wstring text;
text = scoreText;
text += buffer;
...
txtHelper..DrawTextLine(text.c_str());
}

Share this post


Link to post
Share on other sites
Since you are using C++:



const std::wstring scoreText = L"Score: ";
UINT score = 0;
...

drawText() {
std:stringstream< wchar_t > ss;
ss << scoreText << score
txtHelper.DrawTextLine(ss.c_str());

}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!