From 33354ae5ebe8ce426fe2704a4de1576f72121464 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Sun, 26 Nov 2023 17:38:43 -0600 Subject: [PATCH] scaling fixes --- server/src/main.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index c601476666840cc1a22be8afd5de4a85962e8e7a..289bec72167d5b60389077b2b8069b628e30fe84 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -44,7 +44,7 @@ fn main() { fn spawn_planets(mut commands: Commands) { info!("Spawning planets"); let earth_pos = Transform::from_xyz(0.0, 0.0, 0.0); - let earth_radius = 100.0; + let earth_radius = 2000.0 / SCALE; commands .spawn(PlanetBundle { planet_type: PlanetType::Earth, @@ -80,7 +80,7 @@ fn on_message( let mut rng = rand::thread_rng(); rng.gen::() * std::f32::consts::PI * 2. }; - let mut transform = Transform::from_xyz(angle.cos() * 210., angle.sin() * 210., 0.0); + let mut transform = Transform::from_xyz(angle.cos() * 2050. / SCALE, angle.sin() * 2050. / SCALE, 0.0); transform.rotate_z(angle); let id = commands .spawn(PlayerBundle { @@ -90,18 +90,19 @@ fn on_message( }, player: Player { addr: *addr, username: username.to_string() }, }) - .insert(Collider::cuboid(10.0, 10.0)) + .insert(Collider::cuboid(25.0 / SCALE, 25.0 / SCALE)) .insert(RigidBody::Dynamic) .id().index(); // tell this player the planets let mut planets = Vec::new(); for (entity, planet_type, transform) in planet_query.iter() { + let translation = transform.translation; planets.push((entity.index(), Planet { planet_type: *planet_type, - transform: proto_transform!(transform), + transform: proto_transform!(Transform::from_translation(translation * SCALE)), radius: match *planet_type { - PlanetType::Earth => 100.0 + PlanetType::Earth => 2000.0 } })); } @@ -133,12 +134,12 @@ fn on_message( for (entity, part_type, transform) in &part_query { parts.push((entity.index(), Part { part_type: *part_type, - transform: proto_transform!(transform), + transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)), })); } parts.push((id, Part { part_type: PartType::Hearty, - transform: proto_transform!(transform), + transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)), })); let packet = Packet::PartPositions { parts @@ -197,7 +198,7 @@ fn on_position_change( let id = commands.entity(entity).id().index(); updated_parts.push((id, Part { part_type: *part_type, - transform: proto_transform!(transform), + transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)), })); } @@ -213,9 +214,9 @@ fn on_position_change( let id = commands.entity(entity).id().index(); planets.push((id, Planet { planet_type: *planet_type, - transform: proto_transform!(transform), + transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)), radius: match *planet_type { - PlanetType::Earth => 100.0, + PlanetType::Earth => 2000.0, } })); }