We use init()
,
set_mode
to
create the window,
pygame.init() surface = pygame.display.set_mode((900,300)) pygame.display.flip()
flip()
is needed to display
it But
**NOTICE in the Video the screen appears briefly behind vs code and in front of the browser, AND IF IT DOESN'T WORK change python interpreter from 3.10.9, or back to 3.13 and (Install pygame in venv) if not working from default
import pygame
if __name__ == '__main__':
pygame.init()
surface = pygame.display.set_mode(
(900,300))
pygame.display.flip()
import the time library and use sleep for 3 seconds
NOTICE how it now stays open for 2 seconds.
import pygame
import time
if __name__ == '__main__':
pygame.init()
surface = pygame.display.set_mode(
(900,300))
pygame.display.flip()
time.sleep(2)
Visit Pygame documentation https://www.pygame.org/docs/ for infomation on function, methods, flag ...
It's a little confusing, you have to dig around, review documentation on the the above
**warning error i received. DO NOT name
script pygame.py