Created
February 19, 2015 18:31
-
-
Save SteveClement/34ffd8959cff02908d0b to your computer and use it in GitHub Desktop.
Simple font example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import pygame, time | |
from pygame.locals import * | |
done = False | |
pygame.init() | |
pygame.font.init() | |
screen = pygame.display.set_mode((320,240)) | |
fontobject = pygame.font.Font(None ,24) | |
all_fonts = pygame.font.get_fonts() | |
print(all_fonts) | |
# Try to play around with other fonts, it failed for me :( | |
#fontobject = pygame.font.Font("gillsans" ,24) | |
message = "Hi Alice, enjoy your day and code well" | |
# Make screen black | |
screen.fill((0, 0, 0)) | |
# Endless loop until clicked on window X or Keyboard ESC | |
while not done: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
done = True | |
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: | |
done = True | |
# Actually draw the stuff to the screen | |
screen.blit(fontobject.render(message, True, (255,255,255)), (0 , 0 )) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment