diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..7b7b8f9725d518fb80e9b5fee7028a6d4c8f4480 --- /dev/null +++ b/README.en.md @@ -0,0 +1,73 @@ + + +# Flappy Dragon + +This is a simple "Flappy Dragon" game project, designed to demonstrate the basics of game development using the Bracket Terminal library. The current version mainly implements game window initialization and basic state rendering. + +## Project Features + +- Written in Rust +- Built using the Bracket Terminal library +- Provides a basic game loop structure +- Simple state management and screen rendering + +## File Structure + +- `src/main.rs`: Contains the main game logic and state management. +- `Cargo.toml`: Dependency management file for the Rust project. +- `.gitignore`: Specifies files to be ignored by Git. +- `.idea/`: Contains IDE (e.g., IntelliJ IDEA) configuration files. + +## Game Main Logic + +The `src/main.rs` file defines the following key components: + +- `State` struct: Used to manage the game state. +- `impl GameState for State`: Implements the tick method of the game loop, responsible for updating the screen and handling game logic. + - `fn tick(&mut self, ctx: &mut BTerm)`: Called once per frame, responsible for clearing the screen and printing text at specified positions. +- `fn main() -> BError`: Initializes the terminal and starts the main game loop. + +## How to Run + +1. Ensure you have the Rust toolchain installed. +2. Run the project using the following command: + ```bash + cargo run + ``` + +## Example Code + +Here is an excerpt of the core code from the project: + +```rust +struct State {} + +impl GameState for State { + fn tick(&mut self, ctx: &mut BTerm) { + // Clear the screen + ctx.cls(); + // Print something to the screen + ctx.print(1, 1, "Hello, Bracket Terminal!"); + } +} + +fn main() -> BError { + println!("Hello, world!"); + let context = BTermBuilder::simple80x50() + .with_title("Flappy Dragon") + .build()?; + main_loop(context, State {})? +} +``` + +## Dependencies + +- `bracket-terminal`: Used for terminal-based graphics and the game loop. + +## Contributions + +Contributions and improvements are welcome! Please follow the project's coding standards and submission guidelines. + +## License + +MIT License - See the [LICENSE](LICENSE) file for details. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bdd97c4d71c72131a80c2a4a593b9d292c353185 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ + + +Based on the information retrieved, here's a README.md tailored for this project: + +```markdown +# Flappy Dragon + +这是一个简单的“Flappy Dragon”游戏项目,旨在演示如何使用Bracket Terminal库进行基础的游戏开发。当前版本主要实现了游戏窗口的初始化及基础状态渲染。 + +## 项目特点 + +- 使用 Rust 编写 +- 基于 Bracket Terminal 库构建 +- 提供基础的游戏循环结构 +- 简单的状态管理和屏幕渲染 + +## 文件结构 + +- `src/main.rs`: 包含主要的游戏逻辑和状态管理。 +- `Cargo.toml`: Rust 项目的依赖管理文件。 +- `.gitignore`: 指定 Git 忽略的文件。 +- `.idea/`: 包含 IDE(如 IntelliJ IDEA)的配置文件。 + +## 游戏主逻辑 + +在 `src/main.rs` 中定义了以下主要组件: + +- `State` 结构体:用于管理游戏状态。 +- `impl GameState for State`: 实现了游戏循环的 tick 方法,用于更新屏幕和处理游戏逻辑。 + - `fn tick(&mut self, ctx: &mut BTerm)`: 每帧调用一次,负责清除屏幕并在指定位置打印文本。 +- `fn main() -> BError`: 初始化终端并启动游戏主循环。 + +## 如何运行 + +1. 确保安装了 Rust 工具链。 +2. 使用以下命令运行项目: + ```bash + cargo run + ``` + +## 示例代码 + +以下是项目中核心代码的摘录: + +```rust +struct State {} + +impl GameState for State { + fn tick(&mut self, ctx: &mut BTerm) { + // Clear the screen + ctx.cls(); + // Print something to the screen + ctx.print(1, 1, "Hello, Bracket Terminal!"); + } +} + +fn main() -> BError { + println!("Hello, world!"); + let context = BTermBuilder::simple80x50() + .with_title("Flappy Dragon") + .build()?; + main_loop(context, State {})? +} +``` + +## 依赖 + +- `bracket-terminal`: 用于终端图形界面和游戏循环。 + +## 贡献 + +欢迎贡献和改进!请确保遵循项目的编码规范和提交准则。 + +## 许可证 + +MIT License - 查看 [LICENSE](LICENSE) 文件以获取更多信息。 +``` \ No newline at end of file