Can't quite understand why. Everything seems correctly indented within the running loop. Let me know if you can spot why the pygame window opens up and immediately closes afterwards. Checked out similar questions, can't see to understand. Maybe I' missing something obvious?
import pygame
import os
WIDTH = 610
HEIGHT = 760
WIN = pygame.display.set_mode((WIDTH,HEIGHT))
FPS = 60
BLACK = (0,0,0)
WHITE = (255,255,255)
GREEN = (0,255,0)
PLAYER = pygame.image.load(os.path.join('src', 'player.png'))
def window():
WIN.fill(BLACK)
WIN.blit(PLAYER)
pygame.display.update()
def main():
clock = pygame.time.Clock()
running = True
while running: #main game loop
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
window()
pygame.quit()
if __name__ == "__main__":
main()