A command-line pixel platformer game for programmers
Project description
TerminalHero - 命令行像素闯关游戏
项目结构
TerminalHero/
├── main.py # 游戏主入口(唯一入口)
├── play.bat # Windows 启动脚本
├── README.md # 项目说明
├── requirements.txt # 依赖文件
├── utils/ # 工具模块
│ ├── __init__.py
│ ├── constants.py # 常量定义
│ └── input_handler.py # 输入处理
├── models/ # 数据模型
│ ├── __init__.py
│ ├── entities.py # 实体类(Player, Enemy等)
│ └── level.py # 关卡系统
└── core/ # 核心逻辑
├── __init__.py
├── renderer.py # 渲染引擎
└── game_engine.py # 游戏引擎
模块化设计
utils/- 工具模块,包含常量和输入处理models/- 数据模型,包含实体和关卡core/- 核心逻辑,包含渲染器和游戏引擎main.py- 唯一入口文件
特性
- 🎮 命令行界面 - 看起来像普通的终端输出,非常隐蔽
- 🏃 流畅的物理引擎 - 重力、跳跃、碰撞检测
- 👾 敌人系统 - 可以踩扁敌人获得分数
- 🪙 金币收集 - 收集金币增加分数
- 🏁 多关卡设计 - 到达大门即可通关
- 💾 分数系统 - 记录你的最高分
- ⏸️ 暂停功能 - 随时暂停游戏
操作说明
| 按键 | 功能 |
|---|---|
A / ← |
向左移动 |
D / → |
向右移动 |
W / ↑ / 空格 |
跳跃 |
P |
暂停/继续游戏 |
Q / ESC |
退出游戏 |
游戏元素
| 符号 | 说明 |
|---|---|
P |
玩家角色 |
██ |
地面 |
▓▓ |
砖块平台 |
▒▒ |
可顶方块(顶一下有金币) |
░░ |
已顶方块 |
│ / ┬ |
管道 |
○ |
金币 |
G |
敌人(板栗仔) |
▒▒ |
大门(终点) |
安装和运行
前提条件
- Python 3.6+
- Windows 系统需要安装
windows-curses:pip install windows-curses
运行游戏
通过 pip 安装后:
terminalhero
Windows 本地运行:
play.bat
或者直接用 Python:
python main.py
开发指南
添加新关卡
编辑 utils/constants.py 中的 LevelConfig 类。
添加新敌人类型
在 models/entities.py 中继承 Enemy 类。
修改物理参数
在 utils/constants.py 中调整 GRAVITY、JUMP_FORCE 等常量。
许可
MIT License - 自由使用和修改
注意: 请合理安排游戏时间,不要影响工作哦!😉
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
terminalhero-1.0.1.tar.gz
(16.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terminalhero-1.0.1.tar.gz.
File metadata
- Download URL: terminalhero-1.0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9cd122e9aa5c7e98657467cd1afe465ba546ad6a12910d4e60af71d8525acfe
|
|
| MD5 |
7876bc2384a87f94b82b130480537e26
|
|
| BLAKE2b-256 |
518a8f7562602e190a617636a88fea4a967f54b55a5a8db036df0c78a99a5857
|
File details
Details for the file terminalhero-1.0.1-py3-none-any.whl.
File metadata
- Download URL: terminalhero-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25ced4da4c75f61d35614c5818b68920a1b3afb0baf382345273ed16e0cb265
|
|
| MD5 |
786eb5184ec37d3f9ec47de605a23b50
|
|
| BLAKE2b-256 |
e5c28dd06b44273e6de862d0ddd6acbd0d2ea65fdeb84ad245114aa0b8a54c62
|