Created
April 20, 2020 20:42
-
-
Save LevBravE/1f65f96f1003705d758d0b47633c19c2 to your computer and use it in GitHub Desktop.
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
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