This repository has been archived on 2026-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Let_it_snow/readme.dm
2025-12-29 13:12:32 +08:00

71 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 雪花飘落音乐播放器
## 项目简介
这是一个使用 Python 和 Pygame 库开发的雪花飘落动画程序,带有背景音乐播放功能。程序创建了一个冬季雪景效果,雪花随机飘落,并可播放背景音乐。
## 功能特性
- **雪花动画效果**150个雪花随机飘落带有左右摇摆的真实效果
- **背景音乐播放**支持MP3格式音乐文件循环播放
- **音乐控制**:按 `ESC` 键可暂停/继续背景音乐
- **窗口显示**800x600像素的雪花飘落场景
## 依赖库
- `pygame` - 游戏开发库,用于图形渲染和音频播放
- `random` - 随机数生成库
- `sys` - 系统相关功能
## 使用方法
### 运行环境
- Python 3.x
- 需要安装 pygame 库
### 安装依赖
```bash
pip install pygame
```
### 运行程序
1. 确保音频文件 `我期待的不是雪.mp3` 与代码文件在同一目录下
2. 执行命令:
```bash
python main.py
```
### 操作说明
- 程序启动后自动播放背景音乐和雪花动画
- 按 `ESC` 键可切换音乐播放/暂停状态
- 关闭窗口可退出程序
## 代码结构
- `play_bgm()` - 背景音乐播放函数
- `WIDTH`, `HEIGHT` - 窗口尺寸设置
- `snowflakes` - 雪花数据列表
- 主循环 - 处理事件、更新动画、渲染画面
## 打包说明
如需将程序打包为可执行文件,可使用 PyInstaller
```bash
pip install pyinstaller
pyinstaller -F -w test.py
```
## 注意事项
- 确保音频文件路径正确,支持 MP3/WAV 格式
- 程序会自动处理音频文件不存在的异常情况
- 音量默认设置为50%0.5