0

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))
1
  • 1
    maybe program ends and it closes window. Do you get any error message ? Did you try to add at least time.sleep(1) or use endless loop while True ? Or maybe on some systems it will not open window if you don't use pygame.events.get(). What system do you use Window/Mac/Linux ? Commented Jul 9, 2019 at 20:27

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.