鱼C论坛

 找回密码
 立即注册
查看: 2576|回复: 4

[已解决]为什么退不出来

[复制链接]
发表于 2022-11-6 11:02:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
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的时候的一个程序。但是当我点窗口的叉后,为什么无法退出???求解,谢谢。
最佳答案
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()
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 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()
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-11-6 11:21:52 | 显示全部楼层

试过了,还是不行
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-11-6 11:33:20 | 显示全部楼层

                               
登录/注册后可看大图
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-11-6 11:46:40 | 显示全部楼层
可以退了,我自己的疏忽,对不起。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-25 19:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表