123456789101112131415161718192021222324252627 |
- import pygame, sys
- from keyboard import is_pressed
- #Initialize pygame and set up window
- pygame.init()
- winSize = (800, 600)
- screen = pygame.display.set_mode(winSize)
- pygame.display.set_caption('Display text')
- #Load font and render text
- myriadProFont = pygame.font.SysFont('Myriad Pro', 48)
- helloWorld = myriadProFont.render('Hello World!', 1, (255, 0, 255), (255, 255, 255))
- while True:
-
- if is_pressed('q'):
- sys.exit()
-
- #Keep screen open and let user exit window using for loop
- for ev in pygame.event.get():
- if ev.type == pygame.QUIT:
- sys.exit()
- screen.blit(helloWorld, (0, 0))
- #Update window
- pygame.display.update()
|