Jump to content
  • Advertisement

Archived

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

Turt99

Displaying game Score

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

if you had a score stored as an integer and you had images for each of the numbers, how would you display it? would you convert it to a string, then step through the array and convert each character back to an integer to represent a item in an array that would be used to display the correct number? the way I see it I''d have an array that would hold some information that I''d use to blit the number to the screen I''d use sprintf() to convert to a string and then I''d move through the string and use each number as the array index.. How would I know how long the string that I got from sprintf was? and does this sound like a good way to approach this? Please visit Turt99 Productions

Share this post


Link to post
Share on other sites
Advertisement
If the score can be multiple digits, then you should probably treat the score as you would treat text. If you have a pictures of all the letters and characters you wish to display, put a handle to each of them in an array and paint them one after another.

e.g. You intend to print all the letters, capital and lower case, numbers and various punctuation.

Enumerate them in an enum:

enum CHARACTERS
{
TURT99_A, =0
TURT99_B,
...
TURT99_COMMA,
NUM_CHARACTERS
};

texture_handle text_texture_handles[NUM_CHARACTERS];

then, for each text item, loop over each character and draw it.

if('A')blahblah[TURT99_A];

[edited by - flangazor on May 1, 2003 12:05:36 PM]

Share this post


Link to post
Share on other sites
I think you just explained the part that I already knew how I was going to do it...

the score will have to be initally stored as an integer so that I can add to it, and then you say I would make it a string, so I got that part with the sprintf()

But once I have a string of the score how can I tell how long it is? I see what you saying with the enum, it would allow me to display text messages as well (which is actually a good thing) I''ll probably make a simple little Font Engine to cover this actually so I can output the messages I''d like..

however, once again I''d like to know given a char array how would I tell where the text is?

Please visit Turt99 Productions

Share this post


Link to post
Share on other sites
I figured this would be done all the time... I guess I can figure most of it out I''m just looking to say.. if I send in a char array how do I know when my text has stopped..



Please visit Turt99 Productions

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
normal c strings are null terminated, meaning there''s a character 0 at the end. When you sprintf(), it tacks it on there for you. This is how functions like strlen() (hint, hint) work.

Share this post


Link to post
Share on other sites
Thanks thats what I needed, I what thinking that it wouldn''t have a termination... thats exactly what I needed...

*Runs off to do some coding*

Please visit Turt99 Productions

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!