Skip to content

Instantly share code, notes, and snippets.

@SET001
Created February 22, 2022 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SET001/577880375132b6ebd76196af14f8e174 to your computer and use it in GitHub Desktop.
Save SET001/577880375132b6ebd76196af14f8e174 to your computer and use it in GitHub Desktop.
use bevy_editor_pls::prelude::*;
use bevy::prelude::*;
use leafwing_input_manager::{InputManagerBundle, prelude::{ActionState, InputMap}, Actionlike, plugin::InputManagerPlugin};
#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum PlayerAction {
Fire,
MoveLeft,
MoveRight,
MoveUp,
MoveDown
}
fn main() {
App::new()
.insert_resource(WindowDescriptor {
title: "Bevy game experiments".to_string(),
width: 1000.0,
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugin(InputManagerPlugin::<PlayerAction>::default())
.add_plugin(EditorPlugin)
.add_startup_system(on_start)
.run();
}
fn on_start(
mut commands: Commands,
){
let input_map = InputMap::new([
(PlayerAction::MoveLeft, KeyCode::Left),
])
.build();
commands.spawn_bundle(InputManagerBundle::<PlayerAction> {
action_state: ActionState::default(),
input_map: input_map
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment