Jump to content
  • Advertisement
Sign in to follow this  
Side Winder

Printing Variables on Screen

This topic is 3902 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'm in the process of making a space game with C++/DirectX and I currently have a function that handles printing normal text on the screen via one of the parameters:
void Game::drawText(const char* text, int red, int green, int blue, int alpha, int x, int y)
{
	    static RECT textbox; 
		SetRect(&textbox,0,0, x, y); 

		dxFont->DrawTextA(NULL, text, -1, &textbox, DT_CENTER | DT_VCENTER, D3DCOLOR_ARGB(red, green, blue, alpha));
}
(I admit I copied most of this function from a member here on the boards - sorry I've forgotten who you are) How do I go about printing the variables instead of just normal text?

Share this post


Link to post
Share on other sites
Advertisement
Can you explain what you mean by variables?
The function just prints texts so you can use functions like itoa and so on to covert variables values into text.

Share this post


Link to post
Share on other sites
Quote:
Original post by doronf
Can you explain what you mean by variables?
The function just prints texts so you can use functions like itoa and so on to covert variables values into text.


Say I have a "lives" variable that has a range of 0-5... I want it to change on the screen in real time for the user to see.

How does the itoa function work? I tried using it but it doesn't work...

Share this post


Link to post
Share on other sites
Pressing 'F1' on it should bring the relevant help.

You can also use fprintf or your favourite C++ streaming function.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!