When i run this pygame program, a window is supposed to pop up, but nothing happens. Am i doing something wrong?
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
Join Stack Overflow to learn, share knowledge, and build your career.
The problem here is that the program ends and closes the window. You should create some sort of game loop to keep the window open. An easy fix is to use an infinite while
loop after the last line.
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
while True:
pass
time.sleep(1)
or use endless loopwhile True
? Or maybe on some systems it will not open window if you don't usepygame.events.get()
. What system do you use Window/Mac/Linux ? – furas Jul 9 '19 at 20:27