Jump to content

  • Log In with Google      Sign In   
  • Create Account

Drawing a variable to the screen?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 K1NNY   Members   -  Reputation: 163

Like
0Likes
Like

Posted 03 October 2012 - 11:28 AM

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?

Sponsor:

#2 JustABeginner   Members   -  Reputation: 123

Like
0Likes
Like

Posted 03 October 2012 - 11:38 AM

Try to find out (or write your own) toString() & toNumber() in Python - implementation in C++ http://cottonvibes.b...ction-in-c.html

Edited by JustABeginner, 03 October 2012 - 11:43 AM.


#3 superman3275   Crossbones+   -  Reputation: 2061

Like
0Likes
Like

Posted 03 October 2012 - 02:22 PM

Use std::to_string (In C++)
int P = 7;
std::string MyString;
MyString = std::to_string(P);
MyText.SetText(MyString);
// Display MyText (MyText is a text object.)

I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


#4 j-locke   Members   -  Reputation: 825

Like
0Likes
Like

Posted 03 October 2012 - 02:41 PM

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

#5 K1NNY   Members   -  Reputation: 163

Like
0Likes
Like

Posted 04 October 2012 - 08:53 AM

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


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.

#6 6677   Members   -  Reputation: 1058

Like
1Likes
Like

Posted 05 October 2012 - 12:50 PM

str(p) will return the string version of p

#7 Pointer2APointer   Members   -  Reputation: 283

Like
0Likes
Like

Posted 05 October 2012 - 02:41 PM

pygame.font.init()
?

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.
Yes, this is red text.

#8 j-locke   Members   -  Reputation: 825

Like
0Likes
Like

Posted 06 October 2012 - 12:07 AM

Font.render looks like what you're after http://pygame.org/docs/ref/font.html#pygame.font.Font




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS