python冷冰冰 发表于 2022-11-6 11:02:11

为什么退不出来

import pygame
from pygame.locals import *
import sys

background_image_filename = 'sushiplate.jpg'
mouse_image_filename = 'fugu.png'

pygame.init()

screen=pygame.display.set_mode((640,480),0,32)
pygame.display.set_caption("Hello,World!")
background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()

while True:
    for event in pygame.event.get():
      if event.type == QUIT:
            pygame.quit()
            sys.exit()

    screen.blit(background,(0,0))

    x,y = pygame.mouse.get_pos()

    x-=mouse_cursor.get_width()/2
    y-=mouse_cursor.get_height()/2

    screen.blit(mouse_cursor,(x,y))

    pygame.display.update()








如上,这是我在学pygame的时候的一个程序。但是当我点窗口的叉后,为什么无法退出???求解,谢谢。

xiaosi4081 发表于 2022-11-6 11:09:46

本帖最后由 xiaosi4081 于 2022-11-6 11:11 编辑


import pygame
from pygame.locals import *
import sys

background_image_filename = 'sushiplate.jpg'
mouse_image_filename = 'fugu.png'

pygame.init()

screen=pygame.display.set_mode((640,480),0,32)
pygame.display.set_caption("Hello,World!")
background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()

while True:
    for event in pygame.event.get():
      if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    screen.blit(background,(0,0))

    x,y = pygame.mouse.get_pos()

    x-=mouse_cursor.get_width()/2
    y-=mouse_cursor.get_height()/2

    screen.blit(mouse_cursor,(x,y))

    pygame.display.update()

python冷冰冰 发表于 2022-11-6 11:21:52

xiaosi4081 发表于 2022-11-6 11:09


试过了,还是不行

python冷冰冰 发表于 2022-11-6 11:33:20

"C:\Users\PJXY\Desktop\第2套世少赛模拟卷\屏幕截图 2022-11-06 113139.png"

python冷冰冰 发表于 2022-11-6 11:46:40

可以退了,我自己的疏忽,对不起。{:5_95:}
页: [1]
查看完整版本: 为什么退不出来