Rename "physics" to "action", the better to go with lights and camera.
This commit is contained in:
parent
f27d75c879
commit
6a79816968
6 changed files with 16 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{geometry::CyberBike, input::InputState, physics::MovementSettings};
|
use crate::{geometry::CyberBike, input::InputState, action::MovementSettings};
|
||||||
|
|
||||||
pub(crate) const CAM_DIST: f32 = 50.0;
|
pub(crate) const CAM_DIST: f32 = 50.0;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ fn setup_giant_sphere(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup_player(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
use crate::physics::PlayerState;
|
use crate::action::PlayerState;
|
||||||
commands
|
commands
|
||||||
.spawn_bundle((
|
.spawn_bundle((
|
||||||
Transform {
|
Transform {
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub mod camera;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
pub mod lights;
|
pub mod lights;
|
||||||
pub mod physics;
|
pub mod action;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
|
||||||
pub fn disable_mouse_trap(mut windows: ResMut<Windows>) {
|
pub fn disable_mouse_trap(mut windows: ResMut<Windows>) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use cyber_rider::{
|
||||||
geometry::CyberGeomPlugin,
|
geometry::CyberGeomPlugin,
|
||||||
input::CyberInputPlugin,
|
input::CyberInputPlugin,
|
||||||
lights::CyberSpaceLightsPlugin,
|
lights::CyberSpaceLightsPlugin,
|
||||||
physics::{CyberPhysicsPlugin, MovementSettings},
|
action::{CyberPhysicsPlugin, MovementSettings},
|
||||||
ui::CyberUIPlugin,
|
ui::CyberUIPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
13
src/ui.rs
13
src/ui.rs
|
@ -1,6 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::physics::PlayerState;
|
use crate::{geometry::PLANET_RADIUS, action::PlayerState};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct UpText;
|
struct UpText;
|
||||||
|
@ -32,10 +32,17 @@ fn setup_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
.insert(UpText);
|
.insert(UpText);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_ui(pstate_query: Query<&PlayerState>, mut text_query: Query<&mut Text, With<UpText>>) {
|
fn update_ui(
|
||||||
|
pstate_query: Query<(&PlayerState, &Transform)>,
|
||||||
|
mut text_query: Query<&mut Text, With<UpText>>,
|
||||||
|
) {
|
||||||
let mut text = text_query.single_mut();
|
let mut text = text_query.single_mut();
|
||||||
let pstate = pstate_query.single();
|
let pstate = pstate_query.single();
|
||||||
text.sections[0].value = format!("{:.2}", pstate.velocity.length());
|
text.sections[0].value = format!(
|
||||||
|
"spd: {:.2}\nalt: {:.2}",
|
||||||
|
pstate.0.velocity.length(),
|
||||||
|
pstate.1.translation.length() - PLANET_RADIUS
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CyberUIPlugin;
|
pub struct CyberUIPlugin;
|
||||||
|
|
Loading…
Reference in a new issue