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
|
@ -90,7 +90,7 @@ fn update_player_vel(
|
||||||
|
|
||||||
// thrust or brake
|
// thrust or brake
|
||||||
vel += xform.forward() * input.throttle * dt * settings.accel;
|
vel += xform.forward() * input.throttle * dt * settings.accel;
|
||||||
|
|
||||||
|
|
||||||
// brake
|
// brake
|
||||||
if input.brake {
|
if input.brake {
|
||||||
|
@ -106,7 +106,7 @@ fn update_player_vel(
|
||||||
let v2 = vel.length_squared().min(100_000.0);
|
let v2 = vel.length_squared().min(100_000.0);
|
||||||
let drag = vel * settings.drag * v2 * dt;
|
let drag = vel * settings.drag * v2 * dt;
|
||||||
vel -= drag;
|
vel -= drag;
|
||||||
|
|
||||||
if !vel.is_finite() {
|
if !vel.is_finite() {
|
||||||
vel = Vec3::ZERO;
|
vel = Vec3::ZERO;
|
||||||
}
|
}
|
|
@ -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