Skip to content

Instantly share code, notes, and snippets.

@thiagodroz
Created May 10, 2018 18:21
Show Gist options
  • Save thiagodroz/3f5ade4983cfe65bd46a11b719dcdb6f to your computer and use it in GitHub Desktop.
Save thiagodroz/3f5ade4983cfe65bd46a11b719dcdb6f to your computer and use it in GitHub Desktop.
import pygame
pygame.init()
width = 800
height = 600
screen = pygame.display.set_mode((width, height))
finished = False
font_1 = pygame.font.Font('./fonts/Roboto-Regular.ttf', 36)
font_2 = pygame.font.Font('./fonts/Pacifico-Regular.ttf', 36)
font_3 = pygame.font.SysFont('freesansbold', 36)
font_4 = pygame.font.SysFont('arial', 36)
clock = pygame.time.Clock()
print(pygame.font.get_fonts())
print(pygame.font.get_default_font())
while not finished:
# Mouse events
for event in pygame.event.get():
if event.type == pygame.QUIT:
finished = True
# Clear screen
screen.fill((0, 0, 0))
f_1 = font_1.render('Test 1', True, (255, 255, 255))
f_2 = font_2.render('Test 2', True, (255, 255, 255))
f_3 = font_3.render('Test 3', True, (255, 255, 255))
f_4 = font_4.render('Test 4', True, (255, 255, 255))
screen.blit(f_1, (10, 10))
screen.blit(f_2, (10, 80))
screen.blit(f_3, (10, 150))
screen.blit(f_4, (10, 220))
# Update the screen
pygame.display.update()
# Reduce the display frequence
clock.tick(1) # 1 Hz or 1/1s = 1s. Wait 1s.
# Close game screen
pygame.display.quit()
# Close pygame
pygame.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment