Sign in to follow this  
iGunSlingeRv2

Display Score in DirectX

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this