Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m11s
91 lines
2.5 KiB
Rust
91 lines
2.5 KiB
Rust
use core::input::{AxisDirection, InputManager, VirtualBinding};
|
|
use std::collections::HashMap;
|
|
|
|
use vulkano::device::{DeviceExtensions, DeviceFeatures};
|
|
use vulkano_util::context::{VulkanoConfig, VulkanoContext};
|
|
use winit::{
|
|
event::MouseButton,
|
|
event_loop::{ControlFlow, EventLoop},
|
|
keyboard::{KeyCode, PhysicalKey},
|
|
};
|
|
|
|
mod core;
|
|
mod game;
|
|
|
|
fn main() {
|
|
env_logger::init();
|
|
|
|
let input_manager = InputManager::new(HashMap::from([
|
|
(
|
|
"move_forward".to_string(),
|
|
vec![
|
|
VirtualBinding::Keyboard(PhysicalKey::Code(KeyCode::KeyW), AxisDirection::Normal),
|
|
VirtualBinding::Keyboard(PhysicalKey::Code(KeyCode::KeyS), AxisDirection::Invert),
|
|
],
|
|
),
|
|
(
|
|
"move_right".to_string(),
|
|
vec![
|
|
VirtualBinding::Keyboard(PhysicalKey::Code(KeyCode::KeyD), AxisDirection::Normal),
|
|
VirtualBinding::Keyboard(PhysicalKey::Code(KeyCode::KeyA), AxisDirection::Invert),
|
|
],
|
|
),
|
|
(
|
|
"mouse_x".to_string(),
|
|
vec![VirtualBinding::MouseX(AxisDirection::Normal)],
|
|
),
|
|
(
|
|
"mouse_y".to_string(),
|
|
vec![VirtualBinding::MouseY(AxisDirection::Normal)],
|
|
),
|
|
(
|
|
"mouse_wheel".to_string(),
|
|
vec![VirtualBinding::MouseWheelY(AxisDirection::Normal)],
|
|
),
|
|
(
|
|
"mouse_left".to_string(),
|
|
vec![VirtualBinding::MouseButton(
|
|
MouseButton::Left,
|
|
AxisDirection::Normal,
|
|
)],
|
|
),
|
|
(
|
|
"mouse_right".to_string(),
|
|
vec![VirtualBinding::MouseButton(
|
|
MouseButton::Right,
|
|
AxisDirection::Normal,
|
|
)],
|
|
),
|
|
]));
|
|
|
|
let device_extensions = DeviceExtensions {
|
|
khr_swapchain: true,
|
|
..Default::default()
|
|
};
|
|
|
|
let device_features = DeviceFeatures {
|
|
dynamic_rendering: true,
|
|
..Default::default()
|
|
};
|
|
|
|
let vulkano_config = VulkanoConfig {
|
|
print_device_name: true,
|
|
device_extensions,
|
|
device_features,
|
|
..Default::default()
|
|
};
|
|
|
|
let vulkano_context = VulkanoContext::new(vulkano_config);
|
|
|
|
let event_loop = EventLoop::new().unwrap();
|
|
event_loop.set_control_flow(ControlFlow::Poll);
|
|
|
|
let mut app = core::app::App::new(vulkano_context, input_manager);
|
|
|
|
match event_loop.run_app(&mut app) {
|
|
Ok(_) => {}
|
|
Err(e) => {
|
|
log::error!("Error running old app: {e}");
|
|
}
|
|
}
|
|
}
|