~starkingdoms/starkingdoms

ffbbb9a837237aeb3a385e918f53d03dd7f96e2d — core 2 years ago bb92723 + 07e8dcf
Merge branch 'master' into 'feat/protobuf-protocol'

# Conflicts:
#   server/src/timer.rs
2 files changed, 6 insertions(+), 5 deletions(-)

M server/src/planet.rs
M spacetime_py/__pycache__/ninja_syntax.cpython-310.pyc
M server/src/planet.rs => server/src/planet.rs +6 -5
@@ 1,3 1,4 @@
use log::debug;
use nalgebra::{Vector2, vector};
use rapier2d_f64::prelude::{RigidBodyHandle, RigidBodySet, ColliderBuilder, RigidBodyBuilder, ColliderSet};
use starkingdoms_protocol::planet::PlanetType;


@@ 5,7 6,7 @@ use starkingdoms_protocol::planet::PlanetType;
use crate::{SCALE, manager::ClientHandlerMessage};

//const GRAVITY: f64 = 0.001;
const GRAVITY: f64 = 0.00006674;
const GRAVITY: f64 = 6.6674;

#[derive(Clone)]
pub struct Planet {


@@ 19,7 20,7 @@ pub struct Planet {
impl Planet {
    pub fn gravity(&self, position: (f64, f64), mass: f64) -> (f64, f64) {
        let distance = ((position.0 - self.position.0).powi(2) + (position.1 - self.position.1).powi(2)).sqrt();
        let force = GRAVITY * ((self.mass * mass) / distance * distance);
        let force = GRAVITY * ((self.mass * mass) / (distance * distance));
        let mut direction = Vector2::new(self.position.0 - position.0, self.position.1 - position.1);
        direction.set_magnitude(force);
        (direction.x, direction.y)


@@ 57,7 58,7 @@ impl Planets {
        Planets::make_planet(
            &mut planets,
            PlanetType::Earth,
            2000.0,
            4000.0,
            1000.0,
            (100.0, 100.0),
            rigid_body_set,


@@ 90,8 91,8 @@ impl Planets {
        let mut direction = Vector2::zeros();
        for planet in self.planets.clone() {
            let planet_grav = planet.gravity(position, mass);
            direction.x = planet_grav.0;
            direction.y = planet_grav.1;
            direction.x += planet_grav.0;
            direction.y += planet_grav.1;
        }
        (direction.x, direction.y)
    }

M spacetime_py/__pycache__/ninja_syntax.cpython-310.pyc => spacetime_py/__pycache__/ninja_syntax.cpython-310.pyc +0 -0