[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Font



I'll check it out.

--- On Wed, 4/8/09, Jake b <ninmonkeys@xxxxxxxxx> wrote:

From: Jake b <ninmonkeys@xxxxxxxxx>
Subject: Re: [pygame] Font
To: pygame-users@xxxxxxxx
Date: Wednesday, April 8, 2009, 3:19 PM

Here's a text class I wrote that I use myself. It automatically creates the text, and caches it for you.

the files are:

text.py : does all the cache-ing, blit-ting, all the 'under the hood' stuff
test_text.py : a bunch of examples on using the text wrapper ( view this file first )
game.py : boilerplate code, don't need to read

== Usage: ==
in Game.init():
# create regular text, and FPS text
hi = Text('Hi world')
fps = FPSText()

in Game.draw(self):
# draw regular text
self.text.draw()

# draw FPS text, and update it
self.fps.draw()
self.fps.tick()

== Notes ==

Text() is 'smart', meaning it will only render the text if needed. the  method .draw() will use a cached version of the render.

Meaning: you can do this, and it only renders once: ( or none if it was already set to that. )

self.text.text="mwhahahaha"
self.text.text="mwhahahaha"
self.text.text="mwhahahaha"


On Tue, Mar 24, 2009 at 8:55 PM, Yanom Mobis <yanom@xxxxxxxxxxxxxx> wrote:
How do you use the font module exactly? I don't care about all the fancy stuff, I just want text in a specific color...




--
Jake