realistic sizes and distances for everything
This commit is contained in:
parent
53dceeb6aa
commit
2d7b787593
|
@ -6,6 +6,7 @@ use bevy::math::DVec3;
|
||||||
use crate::{actor, nature, world};
|
use crate::{actor, nature, world};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
use std::f64::consts::PI as PI64;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct CommandsPlugin;
|
pub struct CommandsPlugin;
|
||||||
|
@ -158,7 +159,7 @@ pub fn load_defs(
|
||||||
mut ew_spawn: EventWriter<SpawnEvent>,
|
mut ew_spawn: EventWriter<SpawnEvent>,
|
||||||
) {
|
) {
|
||||||
let re1 = Regex::new(r"^\s*([a-z_-]+)\s+(.*)$").unwrap();
|
let re1 = Regex::new(r"^\s*([a-z_-]+)\s+(.*)$").unwrap();
|
||||||
let re2 = Regex::new("\"([^\"]*)\"|(-?[0-9]+(?:\\.[0-9]+)?)|([a-zA-Z_-][a-zA-Z0-9_-]*)").unwrap();
|
let re2 = Regex::new("\"([^\"]*)\"|(-?[0-9]+[0-9e-]*(?:\\.[0-9e-]+)?)|([a-zA-Z_-][a-zA-Z0-9_-]*)").unwrap();
|
||||||
let defs_string = include_str!("defs.txt");
|
let defs_string = include_str!("defs.txt");
|
||||||
let mut lines = defs_string.lines();
|
let mut lines = defs_string.lines();
|
||||||
let mut state = ParserState::default();
|
let mut state = ParserState::default();
|
||||||
|
|
25
src/defs.txt
25
src/defs.txt
|
@ -1,14 +1,15 @@
|
||||||
actor 0 0 0 jupiter
|
actor 0 0 0 jupiter
|
||||||
id jupiter
|
id jupiter
|
||||||
scale 400000
|
scale 71492e3
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
rotationx -0.50
|
rotationx -0.50
|
||||||
rotationz -0.28
|
rotationz -0.28
|
||||||
angularmomentum 30 30 30
|
angularmomentum 30 30 30
|
||||||
|
|
||||||
actor -300000 0 -500000 suit
|
actor 0 0 0 suit
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
|
orbit 150000e3 0.66
|
||||||
player yes
|
player yes
|
||||||
id player
|
id player
|
||||||
mass 200.0
|
mass 200.0
|
||||||
|
@ -32,36 +33,40 @@ actor 10 -30 20 MeteorAceGT
|
||||||
mass 3000
|
mass 3000
|
||||||
angularmomentum 0.1 0.1 0.3
|
angularmomentum 0.1 0.1 0.3
|
||||||
|
|
||||||
actor -735000 0 -935000 io
|
actor 0 0 0 io
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 10188
|
orbit 421700e3 0.75
|
||||||
|
scale 1822e3
|
||||||
rotationy -0.40
|
rotationy -0.40
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0.0001 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
|
||||||
actor -1200000 200000 1400000 europa
|
actor 0 0 0 europa
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 8733
|
orbit 670900e3 0.35
|
||||||
|
scale 1561e3
|
||||||
rotationy 0.20
|
rotationy 0.20
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0.0001 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
|
||||||
actor 2200000 0 -1500000 ganymede
|
actor 0 0 0 ganymede
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 14737
|
orbit 1070400e3 0.93
|
||||||
|
scale 2634e3
|
||||||
rotationy -0.40
|
rotationy -0.40
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0.0001 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
|
||||||
actor -4300000 0 1000000 callisto
|
actor 0 0 0 callisto
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 13484
|
orbit 1882700e3 0.45
|
||||||
|
scale 2410e3
|
||||||
rotationy -0.40
|
rotationy -0.40
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0.0001 0
|
||||||
sphere yes
|
sphere yes
|
||||||
|
|
31
src/world.rs
31
src/world.rs
|
@ -5,6 +5,7 @@ use bevy::math::DVec3;
|
||||||
use bevy_xpbd_3d::prelude::*;
|
use bevy_xpbd_3d::prelude::*;
|
||||||
use bevy_xpbd_3d::plugins::sync::SyncConfig;
|
use bevy_xpbd_3d::plugins::sync::SyncConfig;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
use std::f64::consts::PI as PI64;
|
||||||
|
|
||||||
const ASTEROID_UPDATE_INTERVAL: f32 = 0.1; // seconds
|
const ASTEROID_UPDATE_INTERVAL: f32 = 0.1; // seconds
|
||||||
const ASTEROID_SIZE: f32 = 100.0;
|
const ASTEROID_SIZE: f32 = 100.0;
|
||||||
|
@ -123,7 +124,7 @@ pub fn setup(
|
||||||
40000.0f32 // Sun
|
40000.0f32 // Sun
|
||||||
} else {
|
} else {
|
||||||
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
||||||
}
|
} * 100.0
|
||||||
};
|
};
|
||||||
let (r, g, b) = nature::star_color_index_to_rgb(star[4]);
|
let (r, g, b) = nature::star_color_index_to_rgb(star[4]);
|
||||||
let star_color_handle = materials.add(StandardMaterial {
|
let star_color_handle = materials.add(StandardMaterial {
|
||||||
|
@ -131,7 +132,7 @@ pub fn setup(
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
let dist = 1e7;
|
let dist = 1e9;
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Star,
|
Star,
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
|
@ -151,8 +152,8 @@ pub fn setup(
|
||||||
info!("Generated {starcount} stars");
|
info!("Generated {starcount} stars");
|
||||||
|
|
||||||
// Add shaded ring
|
// Add shaded ring
|
||||||
let ring_radius = 640000.0;
|
let ring_radius = 229_000_000.0;
|
||||||
let jupiter_radius = 200000.0;
|
let jupiter_radius = 71_492_000.0;
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
MaterialMeshBundle {
|
MaterialMeshBundle {
|
||||||
mesh: meshes.add(Mesh::from(Cylinder::new(ring_radius, 1.0))),
|
mesh: meshes.add(Mesh::from(Cylinder::new(ring_radius, 1.0))),
|
||||||
|
@ -164,7 +165,8 @@ pub fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Position::from_xyz(0.0, 0.0, 0.0),
|
Position::from_xyz(0.0, 0.0, 0.0),
|
||||||
Rotation::from(Quat::from_rotation_z(1f32.to_radians())),
|
//Rotation::from(Quat::IDENTITY),
|
||||||
|
Rotation::from(Quat::from_rotation_z(0.1f32.to_radians())),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,10 +175,11 @@ fn generate_asteroids(
|
||||||
) {
|
) {
|
||||||
let maxdist = 30;
|
let maxdist = 30;
|
||||||
let maxdist_orthogonal = maxdist / 4;
|
let maxdist_orthogonal = maxdist / 4;
|
||||||
let pi = PI as f64;
|
let player_r: f64 = 150000e3; // sync this with defs.txt parameters
|
||||||
let player_x: f64 = -300000.0;
|
let player_phase: f64 = 0.66; // sync this with defs.txt parameters
|
||||||
|
let player_x: f64 = player_r * (player_phase * PI64 * 2.0).cos();
|
||||||
let player_y: f64 = 0.0;
|
let player_y: f64 = 0.0;
|
||||||
let player_z: f64 = -500000.0;
|
let player_z: f64 = player_r * (player_phase * PI64 * 2.0).sin();
|
||||||
let offset: f64 = 500.0;
|
let offset: f64 = 500.0;
|
||||||
let dist: f64 = 8e3;
|
let dist: f64 = 8e3;
|
||||||
for i in -maxdist..maxdist {
|
for i in -maxdist..maxdist {
|
||||||
|
@ -189,9 +192,9 @@ fn generate_asteroids(
|
||||||
is_spawned: false,
|
is_spawned: false,
|
||||||
spawned_once: false,
|
spawned_once: false,
|
||||||
pos: DVec3::new(
|
pos: DVec3::new(
|
||||||
player_x + offset + dist * i + wobble * (j+k/pi).sin() * (k+j/pi).cos(),
|
player_x + offset + dist * i + wobble * (j+k/PI64).sin() * (k+j/PI64).cos(),
|
||||||
player_y + offset + dist * j + wobble * (k+i/pi).sin() * (i+k/pi).cos(),
|
player_y + offset + dist * j + wobble * (k+i/PI64).sin() * (i+k/PI64).cos(),
|
||||||
player_z + offset + dist * k + wobble * (i+j/pi).sin() * (j+i/pi).cos(),
|
player_z + offset + dist * k + wobble * (i+j/PI64).sin() * (j+i/PI64).cos(),
|
||||||
),
|
),
|
||||||
size: ASTEROID_SIZE,
|
size: ASTEROID_SIZE,
|
||||||
class: (((i+j+k) as i32) % 2) as u8,
|
class: (((i+j+k) as i32) % 2) as u8,
|
||||||
|
@ -307,11 +310,9 @@ fn handle_despawn(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_cheats(
|
fn handle_cheats(
|
||||||
mut commands: Commands,
|
|
||||||
key_input: Res<ButtonInput<KeyCode>>,
|
key_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
|
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
|
||||||
mut q_life: Query<(&mut actor::LifeForm, ), With<actor::Player>>,
|
mut q_life: Query<(&mut actor::LifeForm, ), With<actor::Player>>,
|
||||||
q_entities: Query<Entity, (With<actor::Actor>, Without<actor::Player>)>,
|
|
||||||
settings: ResMut<settings::Settings>,
|
settings: ResMut<settings::Settings>,
|
||||||
) {
|
) {
|
||||||
if !settings.dev_mode || q_player.is_empty() || q_life.is_empty() {
|
if !settings.dev_mode || q_player.is_empty() || q_life.is_empty() {
|
||||||
|
@ -338,10 +339,6 @@ fn handle_cheats(
|
||||||
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -1000.0));
|
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -1000.0));
|
||||||
}
|
}
|
||||||
if key_input.pressed(settings.key_cheat_adrenaline_zero) {
|
if key_input.pressed(settings.key_cheat_adrenaline_zero) {
|
||||||
// NOTE: temporarily added despawn all in here
|
|
||||||
for entity in &q_entities {
|
|
||||||
commands.entity(entity).despawn();
|
|
||||||
}
|
|
||||||
lifeform.adrenaline = 0.0;
|
lifeform.adrenaline = 0.0;
|
||||||
}
|
}
|
||||||
if key_input.pressed(settings.key_cheat_adrenaline_mid) {
|
if key_input.pressed(settings.key_cheat_adrenaline_mid) {
|
||||||
|
|
Loading…
Reference in a new issue