move_hw_text.py 798 B

123456789101112131415161718192021222324252627282930313233
  1. import pygame, sys
  2. #Initialize pygame and set up window
  3. pygame.init()
  4. winSize = (800, 600)
  5. screen = pygame.display.set_mode(winSize)
  6. #Load font and render text
  7. myriadProFont = pygame.font.SysFont('Myriad Pro', 48)
  8. helloWorld = myriadProFont.render('Hello World!', 1, (255, 0, 255), (255, 255, 255))
  9. #Create x and y coordinate variables for displaying text on screen
  10. x, y = 0, 0
  11. #Add clock so that the next frame is displayed at an exact time
  12. clock = pygame.time.Clock()
  13. while 1:
  14. clock.tick(40)
  15. #Keep screen open and let user exit window using for loop
  16. for ev in pygame.event.get():
  17. if ev.type == pygame.QUIT:
  18. sys.exit()
  19. screen.fill((0,0,0))
  20. screen.blit(helloWorld, (x, y))
  21. x += 6
  22. pygame.display.update()