Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

viper716

Displaying the score???

This topic is 5529 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

Ok I’m using DrawText to display the Score, it only allows you to display strings. How do you convert a integer value to a string? I’m sure I’ve done this before only I’ve completely forgot. Using C++, Windows Environment.

Share this post


Link to post
Share on other sites
Advertisement
Or stringstreams. They're somewhat more convenient, I think.


#include <sstream>
...
std::stringstream str;
str << iScore;
DrawText(str.str().c_str());




[edited by - micepick on May 28, 2003 4:05:02 PM]

Share this post


Link to post
Share on other sites
Ok when I said windows environment i meant dialog based. None of those two work. The include file stringstreams isn''t recognised unless you mean cstring? It also doesn''t like sprintf.

Also what’s the i for?

thanks

Share this post


Link to post
Share on other sites
For std::stringstream you should include sstream, as in:

#include <sstream>

It should then work. The 'i' part of the variable name is just to show you that it is an int (integer). You do not have to name it this, it just adds clarity to the example.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 28, 2003 4:05:44 PM]

Share this post


Link to post
Share on other sites
A RGB color encoded in a COLORREF has a trivial format in hexadecimal:

0x00BBGGRR

where BB, GG, RR are intensities of each color, from 00 to FF.
The brightest green is then 0x0000FF00.

Share this post


Link to post
Share on other sites
Ok I have two new problems now

How do I space out the text I have on the same line? i.e
Score: 230

Here’s what I’ve got:
dc.DrawText(("SCORE: "),-1,&m_WinRect,DT_SINGLELINE);
dc.DrawText((str.str().c_str()),&m_WinRect, DT_SINGLELINE);

Also how do I update the score? The variable does seem to be working only the DrawText isn’t updated it. I figured maybe you keep redrawing it but that doesn’t work.

Any Ideas?

Thanks
I''ll get there soon

Share this post


Link to post
Share on other sites

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