Basic program

Esempio ufficiale: https://www.pygame.org/docs/tut/tom_games2.html

Codice

import pygame
 
pygame.init()

SCREEN = pygame.display.set_mode((800, 450))
pygame.display.set_caption('Basic program')

FONT    = pygame.font.Font(None, 100)
TEXT    = FONT.render("Hello There", 1, (0, 0, 100))
textpos = TEXT.get_rect()

BACKGROUND = pygame.Surface(SCREEN.get_size())
BACKGROUND.fill((255, 255, 200))
textpos.centerx = BACKGROUND.get_rect().centerx
textpos.centery = BACKGROUND.get_rect().centery

BACKGROUND.blit(TEXT, textpos)
SCREEN.blit(BACKGROUND, (0, 0))
pygame.display.flip()

Codice originale

...

Lascia un commento