2

I'm following along with this tutorial: https://www.youtube.com/watch?v=jO6qQDNa2UY&t=1444s&ab_channel=TechWithTim

My code is the same from the video but the pygame.QUIT isn't working. It was before but not sure what happened.

Here's my code

import pygame
import os

WIDTH, HEIGHT = 900, 500   #Y, X
WIN = pygame.display.set_mode((WIDTH, HEIGHT))

pygame.display.set_caption("First Game!")

#definding varibles#
WHITE = (255, 255, 255)
FPS = 60
SPACESHIP_WIDTH, SPACESHIP_HEIGHT = 55, 40

#inporting images    these images in pygame are know as surfaces
YELLOW_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Assets', 'spaceship_yellow.png'))
YELLOW_SPACESHIP = pygame.transform.scale(YELLOW_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT))

RED_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Assets', 'spaceship_red.png'))
RED_SPACESHIP = pygame.transform.scale(RED_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT))

def draw_window(): 
    WIN.fill(WHITE)
    WIN.blit(YELLOW_SPACESHIP, (300,100))
    pygame.display.update()


def main():
    clock = pygame.time.Clock()
    run = True
    while run:
        clock.tick(FPS)    #ensurces that we will not go over our FPS, makes the game consistent on diff computers
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        draw_window()


    pygame.quit() 
   
    

if __name__ == "__main__":
    main()

Any help is appreciated!

MilkShake
  • 27
  • 2

0 Answers0