mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
testing
This commit is contained in:
parent
83f06950e2
commit
e68e0b39e3
|
@ -0,0 +1,18 @@
|
|||
use glam::{Mat4, EulerRot, Quat};
|
||||
use shipyard::{Component, View, ViewMut, IntoIter, UniqueView};
|
||||
use crate::{transform::Transform, input::Inputs};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct FlyController;
|
||||
|
||||
pub fn update_controllers(
|
||||
controllers: View<FlyController>,
|
||||
mut transforms: ViewMut<Transform>,
|
||||
inputs: UniqueView<Inputs>
|
||||
) {
|
||||
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
||||
let (scale, mut rotation, translation) = transform.0.to_scale_rotation_translation();
|
||||
rotation *= Quat::from_euler(EulerRot::XYZ, 0., 0.001, 0.);
|
||||
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
||||
}
|
||||
}
|
14
src/main.rs
14
src/main.rs
|
@ -32,6 +32,7 @@ use settings::GameSettings;
|
|||
use camera::compute_cameras;
|
||||
use events::{clear_events, process_glutin_events};
|
||||
use input::{init_input, process_inputs};
|
||||
use fly_controller::update_controllers;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub(crate) struct DeltaTime(Duration);
|
||||
|
@ -47,9 +48,9 @@ fn startup() -> Workload {
|
|||
fn update() -> Workload {
|
||||
(
|
||||
process_inputs,
|
||||
update_controllers,
|
||||
update_loaded_world_around_player,
|
||||
compute_cameras,
|
||||
clear_events
|
||||
compute_cameras
|
||||
).into_workload()
|
||||
}
|
||||
fn render() -> Workload {
|
||||
|
@ -58,6 +59,11 @@ fn render() -> Workload {
|
|||
draw_world,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
fn after_frame_end() -> Workload {
|
||||
(
|
||||
clear_events,
|
||||
).into_workload()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
logging::init();
|
||||
|
@ -78,6 +84,7 @@ fn main() {
|
|||
world.add_workload(startup);
|
||||
world.add_workload(update);
|
||||
world.add_workload(render);
|
||||
world.add_workload(after_frame_end);
|
||||
|
||||
//Run startup systems
|
||||
world.run_workload(startup).unwrap();
|
||||
|
@ -123,6 +130,9 @@ fn main() {
|
|||
//Finish rendering
|
||||
let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||
target.0.finish().unwrap();
|
||||
|
||||
//FrameEnd
|
||||
world.run_workload(after_frame_end).unwrap();
|
||||
},
|
||||
_ => (),
|
||||
};
|
||||
|
|
|
@ -2,7 +2,8 @@ use glam::Mat4;
|
|||
use shipyard::{Component, EntitiesViewMut, ViewMut};
|
||||
use crate::{
|
||||
transform::Transform,
|
||||
camera::Camera,
|
||||
camera::Camera,
|
||||
fly_controller::FlyController,
|
||||
};
|
||||
|
||||
#[derive(Component)]
|
||||
|
@ -11,26 +12,35 @@ pub struct LocalPlayer;
|
|||
#[derive(Component)]
|
||||
pub struct Player;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct MainPlayer;
|
||||
|
||||
pub fn spawn_player (
|
||||
mut entities: EntitiesViewMut,
|
||||
mut vm_player: ViewMut<Player>,
|
||||
mut vm_main_player: ViewMut<MainPlayer>,
|
||||
mut vm_local_player: ViewMut<LocalPlayer>,
|
||||
mut vm_transform: ViewMut<Transform>,
|
||||
mut vm_camera: ViewMut<Camera>,
|
||||
mut vm_controls: ViewMut<FlyController>,
|
||||
) {
|
||||
log::info!("spawning player");
|
||||
entities.add_entity(
|
||||
(
|
||||
&mut vm_player,
|
||||
&mut vm_main_player,
|
||||
&mut vm_local_player,
|
||||
&mut vm_transform,
|
||||
&mut vm_camera,
|
||||
&mut vm_controls
|
||||
),
|
||||
(
|
||||
Player,
|
||||
MainPlayer,
|
||||
LocalPlayer,
|
||||
Transform(Mat4::default()),
|
||||
Camera::default()
|
||||
Camera::default(),
|
||||
FlyController
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue