|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- >>> from pygame import *
- pygame 2.3.0 (SDL 2.24.2, Python 3.9.9)
- Hello from the pygame community. (提示不能发表链接,本来这里是pygame的官方文档链接)
- >>> screen = display.set_mode((640, 480))
- >>> font = pygame.font.SysFont('arial', 10)
- Traceback (most recent call last):
- File "<pyshell#2>", line 1, in <module>
- font = pygame.font.SysFont('arial', 10)
- NameError: name 'pygame' is not defined
- >>> font = font.SysFont('arial', 10)
- Traceback (most recent call last):
- File "<pyshell#3>", line 1, in <module>
- font = font.SysFont('arial', 10)
- File "D:\Python\lib\site-packages\pygame\sysfont.py", line 459, in SysFont
- return constructor(fontname, size, set_bold, set_italic)
- File "D:\Python\lib\site-packages\pygame\sysfont.py", line 377, in font_constructor
- font = Font(fontpath, size)
- pygame.error: font not initialized
复制代码
- import pygame
- pygame.init()
- # 创建屏幕窗口并设置标题
- screen = pygame.display.set_mode((500, 500))
- pygame.display.set_caption("白色窗口")
- # 将屏幕填充为白色
- screen.fill((255, 255, 255))
- # 更新窗口显示的内容
- pygame.display.flip()
- # 循环监听事件
- running = True
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- # 监听到窗口关闭事件后退出循环
- running = False
- # 退出pygame
- pygame.quit()
复制代码
|
|