I am coming back to pygame after around one and a half months of taking a break.
I tried to open and create a window i tried to run it and the window immidiatly closed.
This is all of the code:
import pygame
pygame.init()
screen_x = 230
screen_y = 230
display = pygame.display.set_mode ((screen_x, screen_y))
I am using vscode if that does anything, this is the first time I have used vscode so if I do not do something right i may not know.
Thank you for helping!
>Solution :
You need an event loop, or else the application will close immediately.
Here is some starter code to do this:
import pygame
# screen object(width,height)
screen_x = 230
screen_y = 230
screen = pygame.display.set_mode((screen_x, screen_y))
# Set the caption of the screen
pygame.display.set_caption('Title')
# Variable to keep our game loop running
running = True
# game loop
while running:
# for loop through the event queue
for event in pygame.event.get():
# Check for QUIT event
if event.type == pygame.QUIT:
running = False