• Advertisement
Sign in to follow this  

Drawing a variable to the screen?

This topic is 1931 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 need help drawing a variable to my game screen. For instance i have a variable that is:

P = 20

and i would like to draw the value the variable contains to the screen. When i try to make a font object it simply errors and says i need to insert an integer or a string. The varible needs to update to change as well so i'm wondering how to handle this?

Share this post


Link to post
Share on other sites
Advertisement
Try to find out (or write your own) toString() & toNumber() in Python - implementation in C++ [url="http://cottonvibes.blogspot.com/2010/10/easy-generic-tostring-function-in-c.html"]http://cottonvibes.b...ction-in-c.html[/url] Edited by JustABeginner

Share this post


Link to post
Share on other sites
Use std::to_string (In C++)
[CODE]
int P = 7;
std::string MyString;
MyString = std::to_string(P);
MyText.SetText(MyString);
// Display MyText (MyText is a text object.)
[/CODE]

Share this post


Link to post
Share on other sites
What is this for? Is this for debugging purposes where printing to the console is enough? Is this like a game's score so it needs to be put on the screen and changed over time? Are you using any particular frameworks for drawing things (pygame, pyglet, qt)?

Share this post


Link to post
Share on other sites
[quote name='j-locke' timestamp='1349296866' post='4986528']
What is this for? Is this for debugging purposes where printing to the console is enough? Is this like a game's score so it needs to be put on the screen and changed over time? Are you using any particular frameworks for drawing things (pygame, pyglet, qt)?
[/quote]

To be specific, it is the nations "popularity" and yes it changes over time. I am using pygame and i have looked through the documentation and haven't found anything to draw a variable to the screen.

Share this post


Link to post
Share on other sites
[sub][CODE]pygame.font.init()[/CODE]?[/sub]
[sub]You can create a class that converts variable values of any kind into font equivalents of letters, numbers, and symbols to write on the screen.[/sub]

Share this post


Link to post
Share on other sites
Font.render looks like what you're after [url="http://pygame.org/docs/ref/font.html#pygame.font.Font"]http://pygame.org/docs/ref/font.html#pygame.font.Font[/url]

Share this post


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

  • Advertisement