aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:22 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:22 +0100
commit8c1406f7a42822d1b020cc672ed99d02eb34d22f (patch)
treee9b3c21520786d2cb9819e46c504e759e4d2d695 /examples
parentb380ad94647c9bc446d5a76bb16dcc286077275a (diff)
feat(render-bsp): process into inputmanager
Diffstat (limited to 'examples')
-rw-r--r--examples/render-bsp/Cargo.toml2
-rw-r--r--examples/render-bsp/src/main.rs27
2 files changed, 28 insertions, 1 deletions
diff --git a/examples/render-bsp/Cargo.toml b/examples/render-bsp/Cargo.toml
index 82e9cb5..dccc9c2 100644
--- a/examples/render-bsp/Cargo.toml
+++ b/examples/render-bsp/Cargo.toml
@@ -6,6 +6,8 @@ edition = "2018"
[dependencies]
stockton-render = { path = "../../stockton-render", features = ["vulkan"] }
+stockton-input = { path = "../../stockton-input" }
+stockton-input-codegen = { path = "../../stockton-input-codegen" }
stockton-types = { path = "../../stockton-types" }
stockton-levels = { path = "../../stockton-levels" }
winit = "^0.21"
diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs
index b18d7f2..96d5e42 100644
--- a/examples/render-bsp/src/main.rs
+++ b/examples/render-bsp/src/main.rs
@@ -17,6 +17,10 @@
//! Renders ./example.bsp
+use stockton_input::{Axis, InputManager};
+#[macro_use]
+extern crate stockton_input_codegen;
+use std::collections::BTreeMap;
use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder};
use stockton_levels::{prelude::*, q3::Q3BSPFile};
@@ -25,6 +29,18 @@ use stockton_render::{
};
use stockton_types::Session;
+#[derive(InputManager, Default, Clone, Debug)]
+struct MovementInputs {
+ #[axis]
+ x: Axis,
+
+ #[axis]
+ y: Axis,
+
+ #[axis]
+ z: Axis,
+}
+
fn main() {
// Initialise logger
simple_logger::SimpleLogger::new()
@@ -54,15 +70,24 @@ fn main() {
let (renderer, tx) = Renderer::new(&window, &bsp);
let new_control_flow = renderer.update_control_flow.clone();
+ // Create the input manager
+ let manager = {
+ let actions = BTreeMap::new();
+ // TODO: An actual control schema
+
+ MovementInputsManager::new(actions)
+ };
+
// Load everything into the session
let mut session = Session::new(
move |resources| {
resources.insert(renderer);
resources.insert(bsp);
+ resources.insert(manager);
},
move |schedule| {
schedule
- .add_system(process_window_events_system())
+ .add_system(process_window_events_system::<MovementInputsManager>())
.add_thread_local(do_render_system::<Q3BSPFile<VulkanSystem>>());
},
);