Создайте окно с цветом фона sc.fill((200, 255, 200)) и

Создайте окно с цветом фона sc.fill((200, 255, 200)) и надписью "Hello Wold" в центре окна.
Дополнительные параметры: codeFlowType: codeWrite codeFlowLang: Python
Создано: 29.06.2023 19:04

Создайте окно с цветом фона sc.fill((200, 255, 200)) и надписью "Hello Wold" в центре окна.

import pygame

# Initialize Pygame
pygame.init()

# Set window size
winWidth = 500
winHeight = 500
window = pygame.display.set_mode((winWidth, winHeight))

# Set background color
background_color = (200, 255, 200)
window.fill(background_color)

# Set font
font = pygame.font.Font(None, 36)

# Set text
text = font.render("Hello World", True, (0, 0, 0))
text_rect = text.get_rect()
text_rect.center = (winWidth // 2, winHeight // 2)

# Blit the text onto the window
window.blit(text, text_rect)

# Update the display
pygame.display.update()

# Run the game loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            pygame.quit()

Окно с цветом фона и надписью "Hello World" в центре окна будет выглядеть примерно так:

screenshot