diff --git a/src/camera.rs b/src/camera.rs index 51f1593..65a3586 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -16,6 +16,7 @@ enum CyberCameras { pub struct DebugCamOffset { pub rot: f32, pub dist: f32, + pub alt: f32, } impl Default for DebugCamOffset { @@ -23,6 +24,7 @@ impl Default for DebugCamOffset { DebugCamOffset { rot: 60.0, dist: 10.0, + alt: 4.0, } } } @@ -84,6 +86,7 @@ fn follow_cyberbike( let mut ncx = bike_xform.to_owned(); ncx.rotate(Quat::from_axis_angle(up, offset.rot.to_radians())); ncx.translation += ncx.forward() * offset.dist; + ncx.translation += ncx.up() * offset.alt; *cam_xform = ncx; cam_xform.look_at(bike_xform.translation, up); } diff --git a/src/glamor.rs b/src/glamor.rs index ab3a259..bd4d46d 100644 --- a/src/glamor.rs +++ b/src/glamor.rs @@ -74,7 +74,8 @@ fn wireframify_lights(mut lights: Query<&mut AnimateCyberLightWireframe>) { pub struct CyberGlamorPlugin; impl Plugin for CyberGlamorPlugin { fn build(&self, app: &mut App) { - app.add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet) + app.insert_resource(ClearColor(Color::rgb(0.408, 0.6236, 0.925))) + .add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet) .add_system(wireframify_lights) .add_plugin(PolylinePlugin); } diff --git a/src/input.rs b/src/input.rs index e075b4e..a0a8014 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,4 +1,7 @@ -use bevy::prelude::*; +use bevy::{prelude::*, utils::HashSet}; + +use crate::camera::DebugCamOffset; + #[derive(Default, Debug, Resource)] pub(crate) struct InputState { pub yaw: f32, @@ -7,6 +10,33 @@ pub(crate) struct InputState { pub pitch: f32, } +fn update_debug_cam(mut offset: ResMut, mut keys: ResMut>) { + let keyset: HashSet<_> = keys.get_pressed().collect(); + let shifted = keyset.contains(&KeyCode::LShift) || keyset.contains(&KeyCode::RShift); + + for key in keyset { + match key { + KeyCode::Left => offset.rot += 5.0, + KeyCode::Right => offset.rot -= 5.0, + KeyCode::Up => { + if shifted { + offset.alt += 0.5; + } else { + offset.dist -= 0.5; + } + } + KeyCode::Down => { + if shifted { + offset.alt -= 0.5; + } else { + offset.dist += 0.5; + } + } + _ => continue, + } + } +} + fn update_input(mut events: EventReader, mut istate: ResMut) { for GamepadEvent { gamepad: _, @@ -46,6 +76,8 @@ fn update_input(mut events: EventReader, mut istate: ResMut().add_system(update_input); + app.init_resource::() + .add_system(update_input) + .add_system(update_debug_cam); } } diff --git a/src/lights.rs b/src/lights.rs index e531eb0..65320bb 100644 --- a/src/lights.rs +++ b/src/lights.rs @@ -122,7 +122,7 @@ fn spawn_static_lights( // up light commands .spawn(PointLightBundle { - transform: Transform::from_xyz(0.0, PLANET_RADIUS + 30.0, 0.0), + transform: Transform::from_xyz(20.0, 100.0, 20.0), point_light: pink_light, ..Default::default() }) @@ -143,7 +143,7 @@ fn spawn_static_lights( // down light commands .spawn(PointLightBundle { - transform: Transform::from_xyz(0.0, -PLANET_RADIUS - 30.0, 0.0), + transform: Transform::from_xyz(-20.0, 100.0, -20.0), point_light: blue_light, ..Default::default() }) diff --git a/src/main.rs b/src/main.rs index 8ee6143..e9c6965 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,6 @@ const MOVEMENT_SETTINGS: MovementSettings = MovementSettings { fn main() { let mut app = App::new(); app.insert_resource(Msaa { samples: 4 }) - .insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02))) .add_plugins(DefaultPlugins.set(WindowPlugin { window: WindowDescriptor { width: 2560.0, diff --git a/src/planet.rs b/src/planet.rs index dcf5317..0b2b68d 100644 --- a/src/planet.rs +++ b/src/planet.rs @@ -17,7 +17,7 @@ fn spawn_planet( mut meshes: ResMut>, mut materials: ResMut>, ) { - let color = Color::rgb(0.2, 0.1, 0.2); + let color = Color::rgba(0.7, 0.7, 0.8, 0.3); let plane = Plane { size: PLANET_RADIUS, };