diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..ce85433 --- /dev/null +++ b/TODO.md @@ -0,0 +1,15 @@ +# v0.1.0 +-[x] contracts + -[x] loby + -[x] actions + -[x] game state +-[ ] way to define default controlls +-[ ] layers for controlls: if on (shift + space) action enable, ignore on (space) action +-[ ] warnings on actions collision +-[ ] basic example + +# v0.2.0 +-[ ] layers for controlls: user posibility give priority to controls +-[ ] controller support +-[ ] touch pad support +-[ ] posibility support more that one game state diff --git a/crate/bevy_controls/example/basic/src/main.rs b/crate/bevy_controls/example/basic/src/main.rs index a5220fb..e80c97e 100644 --- a/crate/bevy_controls/example/basic/src/main.rs +++ b/crate/bevy_controls/example/basic/src/main.rs @@ -21,6 +21,7 @@ enum MyAction { Left, Right, Up, + Down, } #[derive(States, PartialEq, Eq, Clone, Hash, Debug, Default, GameState)] @@ -55,9 +56,19 @@ struct JumpsCount(i32); fn main() { App::new() .add_plugins(( - DefaultPlugins, + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + transparent: true, + decorations: false, + #[cfg(target_os = "macos")] + composite_alpha_mode: CompositeAlphaMode::PostMultiplied, + ..default() + }), + ..default() + }), ControlsPlugin::::default(), )) + .insert_resource(ClearColor(Color::NONE)) .init_resource::() .add_systems(Startup, (add_bindings, setup)) .add_systems(Update, text_update_system) @@ -127,6 +138,13 @@ fn add_bindings(mut controls: ResMut>) { Keyboard::KeyCode(KeyCode::Space), ))), ); + controls.force_push( + MyAction::Down, + Binding::new(ButtonCombination::Chord(vec![ + InputType::Keyboard(Keyboard::KeyCode(KeyCode::ShiftLeft)), + InputType::Keyboard(Keyboard::KeyCode(KeyCode::Space)), + ])), + ); } #[derive(Component)] @@ -140,7 +158,7 @@ fn setup(mut commands: Commands) { commands.spawn(( TextBundle::from_sections([ TextSection::new( - "\nAction: ", + "Action: ", TextStyle { font_size: TEXT_SIZE, ..default() @@ -181,7 +199,8 @@ fn setup(mut commands: Commands) { ..default() }, ), - ]), + ]) + .with_background_color(Color::BLACK), TextBlock, )); } @@ -215,6 +234,13 @@ fn text_update_system( **jumps_count += 1; text.sections[JUMP_INDEX].value = format!("Up (Space) - {}", **jumps_count); } + if player_inputs + .get_just_pressed(MyAction::Down) + .unwrap_or(false) + { + **jumps_count -= 1; + text.sections[JUMP_INDEX].value = format!("Up (Space) - {}", **jumps_count); + } } } diff --git a/crate/bevy_controls/script/fetures-clippy.sh b/crate/bevy_controls/script/fetures-clippy.sh index a713549..0b5ce3c 100644 --- a/crate/bevy_controls/script/fetures-clippy.sh +++ b/crate/bevy_controls/script/fetures-clippy.sh @@ -7,7 +7,7 @@ log "enable logging" while [ "$#" -gt 0 ]; do case $1 in - -h|-?|--help|help) + -h|--help|help) HELP=1 ;; -*) diff --git a/index.html b/index.html new file mode 100644 index 0000000..b8ab208 --- /dev/null +++ b/index.html @@ -0,0 +1,3 @@ +
    +
  • [ ]
  • +