一个使用Python开发的经典游戏集合,包含多款精心制作的休闲游戏。
1. 贪吃蛇 (Snake)
- Python 3.x
- 依赖库:
pygame(用于游戏开发)
pip install pygame- 克隆仓库:
git clone https://github.com/xjn2005/MyPyGames.git- 进入游戏目录:
cd MyPyGames/snake # 或 cd MyPyGames/tetris- 运行游戏:
python game.py # 贪吃蛇游戏
# 或 python tetris.py # 俄罗斯方块游戏如果你想将游戏打包成可执行文件分发给朋友:
- 安装打包工具:
pip install pyinstaller- 打包普通游戏(如俄罗斯方块):
pyinstaller --onefile --windowed tetris.py- 打包带有外部资源的游戏(如贪吃蛇):
pyinstaller --onefile --windowed --add-data "PressStart2P-Regular.ttf;." game.py- 最终可执行文件将生成在
dist目录下。
MyPyGames/
├── snake/ # 贪吃蛇游戏
│ ├── game.py # 游戏主程序
│ ├── snake.py # 蛇类实现
│ ├── food.py # 食物类实现
│ ├── obstacle.py # 障碍物类实现
│ ├── screen.py # 屏幕管理
│ ├── settings.py # 游戏设置
│ └── PressStart2P-Regular.ttf # 字体文件
├── tetris/ # 俄罗斯方块游戏
│ ├── tetris.py # 游戏主程序
│ ├── rank.py # 排行榜功能
│ └── settings.py # 游戏设置
├── LICENSE # 许可证文件
└── README.md # 项目说明
欢迎提交 Issue 和 Pull Request 来帮助改进这个项目!
- Fork 仓库
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 打开 Pull Request
本项目采用 Apache-2.0 许可证 - 查看 LICENSE 文件了解详情。
如有问题或建议,欢迎通过 GitHub Issues 与我联系。
享受游戏的乐趣! 🎉


