Crates.io | kurinji |
lib.rs | kurinji |
version | 1.0.5 |
source | src |
created_at | 2020-11-21 07:07:04.275047 |
updated_at | 2020-12-22 13:25:31.291449 |
description | Input map for bevy |
homepage | |
repository | https://github.com/PradeepKumarRajamanickam/kurinji |
max_upload_size | |
id | 314605 |
size | 407,978 |
Input map plugin for bevy
(Note* Previously called bevy_prototype_input_map)
Decouples gameplay code from device specific input api. Converts user inputs from different input hardware into game specific actions, eg. keyboard "Space" or joystick "A" can be mapped to "Jump" Action.
Add to Cargo.toml dependencies
[dependencies]
kurinji = "*"
fn main() {
App::build()
.add_plugin(KurinjiPlugin::default())
.add_startup_system(setup.system())
.add_system(system.system())
.run();
}
fn setup(
mut kurinji: ResMut<Kurinji>,
) {
// with data
// refer "example/config/gamepad.ron"
let binding_ron = fs::read_to_string("example/config/gamepad.ron").unwrap()
kurinji.set_bindings_with_ron(&binding_ron);
// or
// via code
kurinji
.bind_keyboard_pressed(KeyCode::Return, "SHOOT")
.bind_mouse_motion(Axis::YNegative, "AIM_UP")
.set_dead_zone("AIM_UP", 0.1)
}
// system
fn system(kurinji: Res<Kurinji>) {
if input_map.is_action_active("SHOOT") {
println!("Bang...");
}
*Check out examples
Use commands
Via Code
cargo run --example keyboard_mouse_with_code
cargo run --example gamepad_with_code
Via JSON/RON
cargo run --example keyboard_mouse_with_json
cargo run --example gamepad_with_ron
For Action Events Usage
cargo run --example with_action_events
Note* Latest commit on master branch might be unstable. Use the release tags if you are looking for stable commits or grab crate from https://crates.io/crates/kurinji
https://github.com/PradeepKumarRajamanickam/kurinji/issues
Pradeep Kumar Rajamanickam
Inspired by