📜  如何在 pyga,e 中创建一个窗口 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:03.453000             🧑  作者: Mango

代码示例1
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()