@@ 13,6 13,7 @@ pub mod packet;
pub mod macros;
const SCALE: f32 = 10.0;
+const EARTH_SIZE: f32 = 1000.0;
fn main() {
let subscriber = tracing_subscriber::FmtSubscriber::new();
@@ 44,13 45,12 @@ 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 = 2000.0 / SCALE;
commands
.spawn(PlanetBundle {
planet_type: PlanetType::Earth,
transform: TransformBundle::from(earth_pos),
})
- .insert(Collider::ball(earth_radius))
+ .insert(Collider::ball(EARTH_SIZE / SCALE))
.insert(RigidBody::Fixed);
}
@@ 80,7 80,7 @@ fn on_message(
let mut rng = rand::thread_rng();
rng.gen::<f32>() * std::f32::consts::PI * 2.
};
- let mut transform = Transform::from_xyz(angle.cos() * 2050. / SCALE, angle.sin() * 2050. / SCALE, 0.0);
+ let mut transform = Transform::from_xyz(angle.cos() * 1100. / SCALE, angle.sin() * 1100. / SCALE, 0.0);
transform.rotate_z(angle);
let id = commands
.spawn(PlayerBundle {
@@ 102,7 102,7 @@ fn on_message(
planet_type: *planet_type,
transform: proto_transform!(Transform::from_translation(translation * SCALE)),
radius: match *planet_type {
- PlanetType::Earth => 2000.0
+ PlanetType::Earth => EARTH_SIZE
}
}));
}
@@ 139,7 139,7 @@ fn on_message(
}
parts.push((id, Part {
part_type: PartType::Hearty,
- transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)),
+ transform: proto_transform!(Transform::from_translation(transform.translation * SCALE).with_rotation(transform.rotation)),
}));
let packet = Packet::PartPositions {
parts
@@ 198,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::from_translation(transform.translation * SCALE)),
+ transform: proto_transform!(Transform::from_translation(transform.translation * SCALE).with_rotation(transform.rotation)),
}));
}
@@ 216,7 216,7 @@ fn on_position_change(
planet_type: *planet_type,
transform: proto_transform!(Transform::from_translation(transform.translation * SCALE)),
radius: match *planet_type {
- PlanetType::Earth => 2000.0,
+ PlanetType::Earth => EARTH_SIZE,
}
}));
}