|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- '''pygame 图形绘制'''
- import pygame
- pygame.init()
- fcolck = pygame.time.Clock()
- screen = pygame.display.set_mode((600, 400))
- pygame.display.set_caption('图形绘制')
- GOLD = 255, 251, 0
- RED = pygame.Color('red')
- white = 255, 255, 255
- GREEN = pygame.Color('green')
- e1rect = pygame.draw.ellipse(screen, GREEN, (50, 50, 500, 300), 3)
- while True:
- pygame.display.flip()
- fcolck.tick(40)
复制代码
为什么我运行以上代码,只我要对窗口进行任何操作窗口就会卡死(未响应),我想应该不是我的电脑配置的问题吧
因为你这个有相应用户关闭事件,上面的代码没有
加上就好了:
- '''pygame 图形绘制'''
- import pygame
- import sys
- pygame.init()
- fcolck = pygame.time.Clock()
- screen = pygame.display.set_mode((600, 400))
- pygame.display.set_caption('图形绘制')
- GOLD = 255, 251, 0
- RED = pygame.Color('red')
- white = 255, 255, 255
- GREEN = pygame.Color('green')
- e1rect = pygame.draw.ellipse(screen, GREEN, (50, 50, 500, 300), 3)
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit(0)
-
- pygame.display.flip()
- fcolck.tick(40)
复制代码
|
|