Reputation: 11
I have python 3.10.5 and Pygame 2.1.2. I dont know whats happening, but my window is not showing up. i have tried changing the code a bit, but nothing seems to be working.
import pygame
WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
def main():
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
if __name__ == '__main__':
main()
Upvotes: 0
Views: 392
Reputation: 4816
I tried out your initial code and found some bits missing as noted in the comments. I did not see any reference to what color would be used for filling your screen along with the missing "display.flip(). Keeping the spirit of your initial code as much intact as possible, following is a code snippet that does present a white game window.
import pygame
pygame.init()
WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
def main():
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
WIN.fill((255, 255, 255)) # Added this
pygame.display.flip() # And this
pygame.quit()
if __name__ == '__main__':
main()
You might also want to check out the following link for other tips Pygame Primer.
Upvotes: 1