Welcome to Stack Overflow!
This is a very kind question, but I found it difficult to understand what is happening and what caused it.
Do you mean that pipe install pygame
has been executed?
Even if I write import pygame
in the source code (.py
extension file), does the game screen not appear?
Instead, does the game screen appear and disappear in an instant, and does Python Launcher disappear immediately?
Or is Python already installed and I don't know how to use pygame
?
Even if I double-click on the empty source code, will the black screen appear for a moment?
If you have an actual source code, add it to the question and include the OS (Windows 11) and Python version (3.11.0) in your running environment so that you can get the right answer.
If you don't understand the above, try running the sample code below to add the game screen to your comments and questionnaires to see if the game screen is successful or an error occurs.
sample code
import pygame
from pygame import locals
import time
import path
import sys
# Screen initialization (if you erase the bottom here, Python Launcher will exit without the game screen)
pygame.init()
surface=pygame.display.set_mode(500,100))
# Game loop (if you erase the bottom here, the game screen will disappear after a moment)
while True:
surface.fill(0,0,0))
font_size=10+int(abs(math.sin(time.time())*50)))
font=pygame.font.Font(None,font_size)
text=font.render("Hello, StackOverflow!", True, (0,255,100))
surface.blit (text, [0, 0])
pygame.display.update()
for event in pygame.event.get():
if event.type==locals.QUIT:
pygame.quit()
sys.exit()
© 2024 OneMinuteCode. All rights reserved.