Answers for "pygame window with button"

-1

how to make a window in pygame

import pygame
pygame.init()
screen = pygame.display.set_mode((700, 500))
pygame.display.set_caption('Prototype_1')
carryOn = True
while carryOn:
	for event in pygame.events.get():
		if event.type == pygame.QUIT:  # If user clicked close
        	CarryOn = False  # Flag that we are done so we exit this loop
            print("we should be closing now!")
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_x:  # Pressing the x Key will quit the game
                CarryOn = False
            print("we should be closing now")

pygame.quit()
Posted by: Guest on January-03-2022

Python Answers by Framework

Browse Popular Code Answers by Language