Rename "physics" to "action", the better to go with lights and camera.

This commit is contained in:
Joe Ardent 2022-01-13 14:28:44 -08:00
parent f27d75c879
commit 6a79816968
6 changed files with 16 additions and 9 deletions

View File

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

View File

@ -1,6 +1,6 @@
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;

View File

@ -44,7 +44,7 @@ fn setup_giant_sphere(
}
fn setup_player(mut commands: Commands, asset_server: Res<AssetServer>) {
use crate::physics::PlayerState;
use crate::action::PlayerState;
commands
.spawn_bundle((
Transform {

View File

@ -4,7 +4,7 @@ pub mod camera;
pub mod geometry;
pub mod input;
pub mod lights;
pub mod physics;
pub mod action;
pub mod ui;
pub fn disable_mouse_trap(mut windows: ResMut<Windows>) {

View File

@ -5,7 +5,7 @@ use cyber_rider::{
geometry::CyberGeomPlugin,
input::CyberInputPlugin,
lights::CyberSpaceLightsPlugin,
physics::{CyberPhysicsPlugin, MovementSettings},
action::{CyberPhysicsPlugin, MovementSettings},
ui::CyberUIPlugin,
};

View File

@ -1,6 +1,6 @@
use bevy::prelude::*;
use crate::physics::PlayerState;
use crate::{geometry::PLANET_RADIUS, action::PlayerState};
#[derive(Component)]
struct UpText;
@ -32,10 +32,17 @@ fn setup_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
.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 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;