Ask coding questions

← Back to all posts
Why won't my Pygame window open?
JacksonEvarts

Does this website not support external windows or something? I went to packages and added it btw.

CODE:

import pygame
pygame.inti()

this is all setting the window up

win = pygame.display.set_mode((500, 500))
pygame.display.set_caption("First Game Kiddo")

creating peramiters regarding the character

x = 50
y = 50
width = 40
height = 60
vel = 5

this is checking if the user has done anything

while is_game_over == False
pygame.time.delay(100)
for event in pygame.event.get ():
if event.type == pygame.QUIT: # if they press X the game will finish
is_game_over == True

Voters
RodJan
JacksonEvarts
Comments
hotnewtop
Vandesm14

You need to create a pygame repl and not a default python repl: https://repl.it/languages/pygame

JambasBots

@Vandesm14 I did that and every time I run it the pygame window opens for a split second then the window goes grey and the project exits.

Vandesm14

@pleb1k You need to put your main code in the main.py file in order for it to run.