What fonts can I use with pygame.font.Font?

There are generally two ways to use fonts in pygame: pygame.font.Font() and pygame.font.SysFont(). pygame.font.Font() expects a path to a font file as its first parameter, whereas pygame.font.SysFont() expects a string with the name of the font. You can load any TrueType font file (*.ttf) with pygame.font.Font(). To load the font file myfont.ttf in your project … Read more

How to Center Text in Pygame

You can always just center the text rectangle when you grab it: # draw text font = pygame.font.Font(None, 25) text = font.render(“You win!”, True, BLACK) text_rect = text.get_rect(center=(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)) screen.blit(text, text_rect) just another option

How can I play an mp3 with pygame?

The play function starts the music playing, but returns immediately. Then your program reaches it’s end, and the pygame object is automatically destroyed which causes the music to stop. As you commented, it does play the music if you wait for it before exiting – because then the pygame object isn’t destroyed until the while … Read more

cons/pros of pygame and pyglet [closed]

pygame is richly active, witness the Aug release of 1.9 with nokia s60 support, enhanced py2app/py2exe support, and a bevvy of experimental features (support for Python 3.1, webcams, gfx, …). Books like Hello World and periodic, fun competitions like ludumdare and pyweek bear witness to the vitality of its community and ecosystem. pyglet has a … Read more

Problems getting pygame to show anything but a blank screen on Macos

Tested and works on macOS 10.15 Catalina, Python 3.7.5, PyGame 2.0.0 (pre-release as of this writing) and PyGame 1.9.6 (stable as of this writing). Initially you need to decide if you want a stable release or a pre-release (unstable). If you decide to use the latest (and possibly pre-release/unstable) then just ignore the first step … Read more