generated from 2ndbeam/bevy-template
- Added input plugin to manage controls config - Added tests for casting InputMap to InputAsset and backwards
44 lines
974 B
Rust
44 lines
974 B
Rust
pub mod player;
|
|
pub mod layout;
|
|
pub mod input;
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
use bevy::prelude::*;
|
|
|
|
pub struct ExpeditionPlugin;
|
|
|
|
pub enum InputActions {
|
|
MoveLeft,
|
|
MoveRight,
|
|
ToggleInventory,
|
|
Interact,
|
|
}
|
|
|
|
fn camera_bundle() -> impl Bundle {
|
|
(
|
|
Camera2d,
|
|
Camera {
|
|
clear_color: ClearColorConfig::Custom(Color::hsl(0.02, 0.67, 0.65)),
|
|
..default()
|
|
},
|
|
Projection::Orthographic(OrthographicProjection {
|
|
scaling_mode: bevy::camera::ScalingMode::FixedVertical {
|
|
viewport_height: 384.,
|
|
},
|
|
scale: 1.,
|
|
..OrthographicProjection::default_2d()
|
|
}),
|
|
)
|
|
}
|
|
|
|
fn setup_global(mut commands: Commands) {
|
|
commands.spawn(camera_bundle());
|
|
}
|
|
|
|
impl Plugin for ExpeditionPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_systems(Startup, (player::setup_player, setup_global))
|
|
.add_systems(Update, player::handle_input);
|
|
}
|
|
}
|