|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
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的时候的一个程序。但是当我点窗口的叉后,为什么无法退出???求解,谢谢。
本帖最后由 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()
复制代码
|
|