1. **pygame.display**
用于管理游戏窗口的显示和设置。
- **函数**:
- `pygame.display.set_mode((width, height))`:创建一个窗口或屏幕。
- `pygame.display.set_caption(title)`:设置窗口标题。
- `pygame.display.flip()`:更新整个屏幕。
- `pygame.display.update(rect)`:更新窗口的指定区域。
- **代码示例**:
```python
import pygame pygame.init() screen = pygame.display.set_mode((640, 480)) pygame.display.set_caption("Pygame Window") pygame.display.flip()
```
2. **pygame.draw**
用于绘制各种形状,如线条、矩形、圆形等。
- **函数**:
- `pygame.draw.line(surface, color, start_pos, end_pos, width)`:绘制直线。