Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

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: 1373

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 photo editor.

Here's Breakout:
Breakout!

If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there Posted Image!

#4 j-locke   Members   -  Reputation: 507

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: 1050

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: 507

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