2 个版本
使用旧的 Rust 2015
0.1.1 | 2017 年 1 月 4 日 |
---|---|
0.1.0 | 2017 年 1 月 4 日 |
#15 在 #adventure
9KB
180 行
act
Act 是一个用于制作基于文本的冒险游戏的简单引擎。
lib.rs
:
Act 是一个用于制作简单、基于文本的冒险游戏的简单引擎。
示例
extern crate act;
use act::load_game;
fn main() {
// Create a string containing our Act game
let game_string = r#"
{
"rooms": [
{
"name": "start",
"scene": "Im a starting room! Welcome to this example game.",
"actions": [
{
"variant": "Move",
"fields": [
"Move to another room","example",""
]
}
]
},
{
"name": "example",
"scene": "You enter an example room, with a big, triangular key in it. Theres also a door with a keyhole in triangular shape.",
"actions": [
{
"variant": "PickUp",
"fields": [
"Pick the key up","TriangleKey",""
]
},
{
"variant": "Move",
"fields": [
"Try to open the door","locked","TriangleKey"
]
}
]
},
{
"name": "locked",
"scene": "You picked an item up and used it to open the door! This is the final room. Congratz!",
"actions": [
{
"variant": "Move",
"fields": [
"Move to another room","example",""
]
}
]
}
]
}
"#;
// Load the game into a proper Game struct
let mut game = load_game(game_string).unwrap();
// Start the game
game.play();
// Profit!
}
依赖关系
~235KB