Skip to content

Instantly share code, notes, and snippets.

@LevBravE
Created April 20, 2020 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LevBravE/1f65f96f1003705d758d0b47633c19c2 to your computer and use it in GitHub Desktop.
Save LevBravE/1f65f96f1003705d758d0b47633c19c2 to your computer and use it in GitHub Desktop.
import pygame
size = width, height = (400, 300)
screen = pygame.display.set_mode(size)
pygame.init()
def draw():
screen.fill((0, 0, 0))
font = pygame.font.Font(None, 50)
text = font.render("Hello, Pygame!", 1, (100, 255, 100))
text_x = width // 2 - text.get_width() // 2
text_y = height // 2 - text.get_height() // 2
text_w = text.get_width()
text_h = text.get_height()
screen.blit(text, (text_x, text_y))
pygame.draw.rect(screen, (0, 255, 0),
(text_x - 10, text_y - 10, text_w + 20, text_h + 20), 1)
draw()
while pygame.event.wait().type != pygame.QUIT:
pygame.display.flip()
pygame.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment